C++ Win32 GUI switch statement error
I'm making a Win32 GUI project using Code::Blocks and the MinGW compiler. At this line of my code:
switch(LOWORD(WPARAM))
which is the switch statement for which menu button was clicked, I get the following error upon compiling:
error: expected primary-expression before ')' token
I found some other cases of this error on other programming forums but the answers didn't help my case. In case you need it, here is the code surrounding the switch statement:
case WM_COMMAND:
switch(LOWORD(WPARAM))
{
case ID_HELP_ABOUT:
MessageBox(hwnd, "--------------", "-----", MB_OK | MB_ICONINFORMATION);
break;
}
break;
The MessageBox text was blan开发者_如何学Cked out. What does the error message mean and is there anything in my code that I can add (or remove) to prevent it?
The problem is that
LOWORD(WPARAM)
Is calling the LOWORD macro on the WPARAM type rather than a variable of type WPARAM. This would be similar to calling
printf(char *);
For example. To fix this, change the code so that it calls LOWORD on a WPARAM variable. Most window procedures name this wParam, so you might want to try
LOWORD(wParam)
WPARAM
is a type not a variable name, you probably meant wParam
or some similar variable name for your switch statement:
switch(LOWORD(wParam))
...
My guess is that wparam
should be lowercase. Can't tell because the exact name is in the function signature that is not visible.
精彩评论