Hi, people. Yesterday I was fighting Windows heroically for almost 5 hours trying to set button text font and color... I won at last, but still confused. Here's my question:
Microsoft gives an example for subclass procedure:
// Subclass procedure
LRESULT APIENTRY EditSubclassProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
if (uMsg == WM_GETDLGCODE)
return DLGC_WANTALLKEYS;
return CallWindowProc(wpOrigEditProc, hwnd, uMsg,
wParam, lParam);
}
So, as I understand, wndproc has to return smth. if a message is processed or invoke CallWindowProc if a message is not processed (as stated in SDK)
For example:
proc ButtonSubclassProc, hWnd, uMsg, wParam, lParam
mov eax, [uMsg]
cmp eax, WM_PAINT
jz .paint
invoke CallWindowProc, <params>
ret
.paint:
<message processing routine>
xor eax, eax
ret
But this makes my app crazy. It consumes 90% of CPU, it redraws the entire dialog, it doesn't work. The solution is simple: invoke CallWindowProc in the beginning, and then process messages (if any).
proc ButtonSubclassProc, hWnd, uMsg, wParam, lParam
invoke CallWindowProc, <params>
mov eax, [uMsg]
cmp eax, WM_PAINT
jz .paint
.ret:
xor eax, eax
ret
.paint:
<message processing routine>
jmp .ret
WHY IS IT SO??? Why should I invoke CallWindowProc and then process messages if Microsoft says to process messages, and invoke CallWindowProc for messages that are not processed???