RELEVANT INFORMATION:
I have a
subclass procedure
that needs to validate the content of the
clipboard
before it gets pasted.
I have managed to get the content of the
clipboard
successfully, at least I think so.
QUESTION:
I do not know how to construct the following
if statement
( the following is pseudo code ):
if( clipboard content is OK )
defaul handler;
else
discard message;
MY EFFORTS TO SOLVE THIS:
So far this is what I have in mind:
LRESULT CALLBACK Decimalni( HWND hwnd,
UINT message, WPARAM wParam, LPARAM lParam,
UINT_PTR uIdSubclass, DWORD_PTR dwRefData )
{
switch (message)
{
case WM_PASTE:
{
bool IsTextValid = true;
if( OpenClipboard(hwnd) ) {
HANDLE hClipboardData;
if( hClipboardData = GetClipboardData(CF_UNICODETEXT) )
{
wchar_t *pchData = (wchar_t*)GlobalLock(hClipboardData);
wchar_t result[10]; memset( result, L'0', sizeof(result) );
wcsncpy_s( result, 10, pchData, _TRUNCATE );
GlobalUnlock(hClipboardData);
}
CloseClipboard();
}
if( IsTextValid )
return ::DefSubclassProc( hwnd, message, wParam, lParam);
else
return FALSE;
}
break;
case WM_CHAR:
{
}
break;
case WM_NCDESTROY:
::RemoveWindowSubclass( hwnd, Decimalni, 0 ); break;
}
return ::DefSubclassProc( hwnd, message, wParam, lParam);
}
Is my idea correct or is there another way to form my
if
statement?
Thank you.
Best regards.