-
Wm_command
I have made a small program with a menu.
In my winproc I thought it would be a good idea to call a function when an menu-option is selected, like this:
Code:
switch(LOWORD(wParam))
{
case MENU_FILE_ID_NEW:
{
menuFileNew();
}break;
...
The function looks like this for the moment:
Code:
void menuFileNew()
{
MessageBox(NULL, "You selected NEW...", "Your choice", MB_OK);
}
The problem is that after the function is executed, the program exits... is there something I have missed? :confused:
-
Try this..
void menuFileNew()
{
MessageBox(NULL, "You selected NEW...", "Your choice", MB_OK);
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case MENU_FILE_ID_NEW:
menuFileNew();
break;
}
break;
-
Nope... didn't work...
The Program still exits :(
-
attatch your code and we will have a look for you.
-
-
Your missing a break
Code:
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case MENU_HELP_ID_ABOUT:
menuHelpAbout();
break;
}break; // THIS ONE
}
Sorry if this is messy, but I'm in a rush at the moment
Later
-
Code:
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
(...)
}
}
case WM_CLOSE:
{
PostQuitMessage(0);
return(0);
}
So the switch statement exits, and it falls through to the next one - which, coincidentally, closes the program.
Then again, had you used a debugger, you would know this already.
You don't need braces around the contents of a case, either.