I have two combobox's on one dialog and I'm processing the CBN_SELCHANGE message inside WM_COMMAND. When I change one combobox, it gets mixed up with my other combobox operations within the same WM_COMMAND. Is there a way to tell which combobox is being switched?
The short answer: yes.
The long answer...check the low order word of the wParam (the high order word contains the CBN_SELCHANGE constant).
so it might look something similar to:
case WM_COMMAND:
{
switch((HIWORD)wParam)
{
case IDC_COMBOBOX1:
switch((LOWORD)wParam)
{
case CBN_SELCHANGE:
break;
}
break;
case IDC_COMBOBOX2:
switch((LOWORD)wParam)
{
case CBN_SELCHANGE:
break;
}
break;
}
}
... ? I don't know what to look for within the HIWORD.
Try:
HIWORD(wParam)
Hmm. MSDN says something about the HWND of the control being in the lParam. I don't seem to be able to do it though. ahhh.
You have it backwards. Check the LOWORD(wParam). That will be the constant identifying the combo box.
Quote from: Okee on December 04, 2004, 10:15 PM
so it might look something similar to:
case WM_COMMAND:
{
switch((HIWORD)wParam)
{
case IDC_COMBOBOX1:
switch((LOWORD)wParam)
{
case CBN_SELCHANGE:
break;
}
break;
case IDC_COMBOBOX2:
switch((LOWORD)wParam)
{
case CBN_SELCHANGE:
break;
}
break;
}
}
... ? I don't know what to look for within the HIWORD.
Once again, I tried something similar to this method. I'm not quite sure where to check within the loword. Will I just be looking for the name of the combobox? I'm confused still, and it has been a week or so. :-(
What are the resource constants defined for the combo boxes? IDC_COMBOBOX1 and IDC_COMBOBOX2?
If so, do something like this:
case WM_COMMAND:
switch( HIWORD(wParam) ) {
case CBNSELCHANGE:
switch( LOWORD(wParam) ) {
case IDC_COMBOBOX1:
doStuff();
break;
case IDC_COMBOBOX2:
doOtherStuff();
break;
default:
break;
}
break;
default:
break;
}
Nice, it's workin now. Thanks.