Article ID: 126820
Article Last Modified on 7/11/2005
SendMessage (hWnd, EM_LIMITEXT, 7, NULL);The user enters ABCDEF ( all single-byte character) to the edit control, then try to enter a double-byte 'G' to the edit control, a GPF will occur.
LONG FAR PASCAL SubClassFunc(HWND hWnd,
WORD Message,
WORD wParam,
LONG lParam)
{
static BOOL bInvalidchar=FALSE; // Is this the last byte?
if ( Message == WM_CHAR )
{
if (bInvalidchar==TRUE) //The trailing byte of a DBCS character
{ //that comes in for the last byte in edit.
bInvalidchar=FALSE; //Reset the flag. Next char is valid.
return 0; //Throw away the trailing byte.
}
else
{
// Is this the last byte? Is the incoming WM_CHAR a DBCS
// leadbyte?
if ( IsDBCSLeadByte(LOBYTE(wParam)) &&
(( TEXTLIMIT - SendMessage(hWnd, WM_GETTEXTLENGTH, 0,0)) == 1))
{
bInvalidchar=TRUE; //The character is invalid.
return 0; // Throw away this byte.
}
else return CallWindowProc(lpfnOldWndProc,
hWnd,
Message,
wParam,
lParam);
}
}
else return CallWindowProc(lpfnOldWndProc,
hWnd,
Message,
wParam,
lParam);
}
Additional query words: cwin jwin fesdk
Keywords: kb16bitonly KB126820