Extracting Data from Messages with Portable Code
The cleanest way to handle a repacked message is to revise your code so that it extracts needed information and stores it in local variables. This localizes message-packing issues to a few lines of your code.
For example, you can use the following code to handle the WM_COMMAND message:
case WM_COMMAND:
id = LOWORD(wParam);
hwndChild = (HWND)(UINT)lParam;
cmd = HIWORD(wParam);