Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » About CExtGridCellNumber Collapse All
Subject Author Date
Paolo Giustinoni Aug 24, 2006 - 11:22 AM

I have a question about the CExtGridCellNumber class.
I have to assign an Integer variable to a CExtGridCellNumber cell.
Using the following code:

int nInitialNumber = 1000;
CExtGridCellNumber* pCell =
STATIC_DOWNCAST (...);
pCell->_VariantAssign(nInitialNumber);

I see in the cell only the value 1

How I can do it?


Technical Support Oct 15, 2007 - 8:40 AM

Unfortunately we cannot reproduce this bug. We tested our cells both with ‘.’ and ‘,’ decimal separators and the results are the same and correct. What should we do exactly to reproduce the problem?

Louis RUBET Oct 4, 2007 - 10:13 AM

hi

sorry guys I encountered the same pb with Prof UIS 2.80 (including the changes you give here) with a currency value (VT_CY).

When I enter somthing like ’120’, I get ’12’ on the cell.

And this problem exist for all real values on systems with decimal separator other than ’.’


-> to solve the pb, I had to add the following lines in CExtGridCellNumberBase::OnQueryNumberText:

(...)
bool bRealNumber = false;
switch( varType&~VT_BYREF )
(...)
if( bRealNumber )
(...)
while( *lpszCur != _T(’\0’) )
{
    if( *lpszCur == _T(’,’) ) //HERE
        *lpszCur = _T(’.’); //HERE
(...)

just as you did in the ’bool bValidate = true’ block.

BUT:

the comparison with decimal char should trust on local settings, or at least on cell setting (ex: using output of CExtGridCellCurrency::OnQueryDecimalSeparator), but it shouldn’t rely on hardcoded chars

Technical Support Aug 25, 2006 - 7:00 AM

Please invoke pCell->_VariantAssign( nInitialNumber, VT_I4 ).

Paolo Giustinoni Aug 25, 2006 - 7:28 AM

Thanks for your answer.
No way.. The problem remain.

Technical Support Aug 28, 2006 - 7:06 AM

The problem is caused by a bug in our code. Please find the CExtGridCellNumberBase::OnQueryNumberText() method and change part of the code after the switch( varType ) line as follows:

bool CExtGridCellNumberBase::OnQueryNumberText( 
    LPCVARIANT pvarValue,
    CExtSafeString & sText 
    ) const
{
    ASSERT_VALID( this );
 
    sText.Empty();
 
LPCVARIANT pVariant = pvarValue;
VARTYPE varType = pVariant->vt;
 
TCHAR szBuf[100] = _T("");
    memset( szBuf, 0, sizeof(szBuf) );
INT nBufSize = sizeof(szBuf)/sizeof(szBuf[0]);
 
    switch( varType ) 
    {
        ...
        ... LEAVE THIS BLOCK UNCHANGED
        ...
    }
 
bool bRealNumber = false;
    switch( varType&~VT_BYREF ) 
    {
    case VT_R4:
    case VT_R8:
    case VT_DATE:
    case VT_CY:
    case VT_DECIMAL:
        bRealNumber = true;
        break;
    }
    if( bRealNumber )
    {
        // trim trailing zero
        LPTSTR lpszCur = szBuf;
        LPTSTR lpszLast = NULL;
        while( *lpszCur != _T(’\0’) )
        {
            if( *lpszCur == _T(’0’) )
            {
                if( lpszLast == NULL )
                    lpszLast = lpszCur;
            }
            else if(    _istdigit(*lpszCur) > 0 
                ||    *lpszCur == _T(’-’)
                ||    *lpszCur == _T(’.’)
                )
                lpszLast = NULL;
            lpszCur = _tcsinc(lpszCur);
        }
        // truncate at left-most zero
        if(        lpszLast != NULL 
            &&    lpszLast != szBuf
            )
            *lpszLast = _T(’\0’);
        
        // if the last symbol is a point - remove it
        if(        lpszLast != NULL
            &&    *(lpszLast - 1) == _T(’.’) 
            ) 
            *(--lpszLast) = _T(’\0’);
    }
 
    // The number string can only contain the following characters: 
    // 1. Characters ’0’ through ’9’. 
    // 2. One decimal point (dot) if the number is a floating-point value. 
    // 3. A minus sign in the first character position if the number is a negative value. 
    // All other characters are invalid.
 
    bool bValidate = true;
    INT nPos = 0;
    LPTSTR lpszCur = szBuf;
    while( *lpszCur != _T(’\0’) )
    {
        if( *lpszCur == _T(’,’) )
            *lpszCur = _T(’.’);
        if(    !(    _istdigit(*lpszCur) > 0 
            ||    *lpszCur == _T(’.’)
            ||    (*lpszCur == _T(’-’) && nPos == 0) )
            )
        {
            bValidate = false;
            break;
        }
        lpszCur = _tcsinc(lpszCur);
        nPos++;
    }
    if( !bValidate )
    {
        ASSERT( FALSE );
        return false;
    }
    sText = szBuf;
    return true;
}

Paolo Giustinoni Aug 28, 2006 - 10:05 AM

I have the following problem regarding the CExtGridCellNumber.
I modified the CExtGridCellNumberBase:: OnQueryNumberText() function based on your suggest, recompiled the DLL, and all works in your examples, but when I try it in my application, the problem remain..
I think that the problem is the configuration of my application: is a simple "Win32 Debug", and your DLL is compiled with "Win32 ANSI Debug". I tried also the "Win32 MBCS Debug" and it’s the same.
How can I set my configuration on Win32 ANSI (or MBCS Debug) to match the correct library, and what is the difference from MBCS configuration?

Thanks in advance, Paolo

Technical Support Aug 28, 2006 - 12:38 PM

Please make sure that you rebuilt the appropriate version of the Prof-UIS library used in your project. The simplest way to determine which version is used is to watch the Output window:

...
Automatically linking with Prof-UIS library: ProfUIS254md.lib
...
254 is the current version number and md means the library configuration.You can learn more about this in the Prof-UIS Build Configurations article.