WM_COMMAND [SOLVED]
-
case WM_COMMAND:
{
if(LOWORD(wParam)==frmMainOK && HIWORD(wParam) == BN_CLICKED)
{
MessageBox(NULL,"OK Pressed","Demo",MB_OK);
}
return TRUE;
}case WM_COMMAND:
{
switch(wParam)
{
case frmMainOK:
MessageBox(NULL,"OK Pressed","Demo",MB_OK);
break;
}
break;
}Which is the correct and most appropriate way between the two examples given above, and why?
Some Day I Will Prove MySelf :: GOLD
modified on Saturday, March 5, 2011 10:37 PM
-
case WM_COMMAND:
{
if(LOWORD(wParam)==frmMainOK && HIWORD(wParam) == BN_CLICKED)
{
MessageBox(NULL,"OK Pressed","Demo",MB_OK);
}
return TRUE;
}case WM_COMMAND:
{
switch(wParam)
{
case frmMainOK:
MessageBox(NULL,"OK Pressed","Demo",MB_OK);
break;
}
break;
}Which is the correct and most appropriate way between the two examples given above, and why?
Some Day I Will Prove MySelf :: GOLD
modified on Saturday, March 5, 2011 10:37 PM
The second bit of code doesn't check the notification code, so if the control sends other codes besides BN_CLICKED, you'll treat those notifications as if they were BN_CLICKED. For buttons, this isn't a problem, but other controls like the edit box send other types of notifications.
--Mike-- Dunder-Mifflin, this is Pam.
-
case WM_COMMAND:
{
if(LOWORD(wParam)==frmMainOK && HIWORD(wParam) == BN_CLICKED)
{
MessageBox(NULL,"OK Pressed","Demo",MB_OK);
}
return TRUE;
}case WM_COMMAND:
{
switch(wParam)
{
case frmMainOK:
MessageBox(NULL,"OK Pressed","Demo",MB_OK);
break;
}
break;
}Which is the correct and most appropriate way between the two examples given above, and why?
Some Day I Will Prove MySelf :: GOLD
modified on Saturday, March 5, 2011 10:37 PM
The second one is logically wrong and (by accident) working just for buttons notifying
BN_CLICKED
. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]