Click to See Complete Forum and Search --> : ComboBox Notification Problems


Fromethius
June 28th, 2007, 01:57 AM
Hello everyone and thank you for taking the time to read my post,

I have this code:


case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case hwndCombo:
{
switch(HIWORD(wParam))
{
case CBN_DROPDOWN:
{
MessageBox(hwnd, "OK", "OK", MB_OK);
} break;
} break;
} break;
} break;
} break;


Also, I have hwndCombo initialized right after I create my window. Don't worry, I know it is initialized before WM_COMMAND runs:

wndCombo = GetDlgItem(hwnd, 30000);

My combobox resource is defined as 30000.





Anyways, when I try to compile this code I get this error:

`hwndCombo' cannot appear in a constant-expression

Thanks for any help given.

S_M_A
June 28th, 2007, 02:00 AM
A switch statement requires constant values for case entries. hwndCombo is a variable so you can't use it at that location. Sad but true... I'd love that it should be possible.

Fromethius
June 28th, 2007, 10:30 AM
So how should I code notifications for a combobox in WM_COMMAND?

S_M_A
June 28th, 2007, 10:35 AM
The easiest way out isif( LOWORD(wParam) == hwndCombo)and so on

VladimirF
June 28th, 2007, 02:58 PM
So how should I code notifications for a combobox in WM_COMMAND?
The low-order word of wParam specifies the control identifier of the combo box, NOT the window's handle (it is in lParam). So your case should be 30000 (and NOT the hwndCombo), which luckily is a constant.

S_M_A
June 28th, 2007, 04:59 PM
Should have checked instead of just assuming code was correct...

VladimirF
June 28th, 2007, 05:35 PM
Should have checked instead of just assuming code was correct...
Yeah... Always check, never assume! ;)