Valhalla Legends Forums Archive | C/C++ Programming | Multiple ComboBox (ComboList)'s on one dialog

AuthorMessageTime
Okee
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?
December 5, 2004, 12:07 AM
Zakath
The short answer: yes.















The long answer...check the low order word of the wParam (the high order word contains the CBN_SELCHANGE constant).
December 5, 2004, 12:53 AM
Okee
so it might look something similar to:

[code]

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;
            }

}

[/code]

... ? I don't know what to look for within the HIWORD.
December 5, 2004, 4:15 AM
UserLoser.
Try:

HIWORD(wParam)
December 5, 2004, 4:30 AM
Okee
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.
December 5, 2004, 4:47 AM
Zakath
You have it backwards. Check the LOWORD(wParam). That will be the constant identifying the combo box.
December 5, 2004, 5:39 AM
Okee
[quote author=Okee link=topic=9781.msg91097#msg91097 date=1102220124]
so it might look something similar to:

[code]

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;
            }

}

[/code]

... ? I don't know what to look for within the HIWORD.
[/quote]

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. :-(
December 15, 2004, 2:33 AM
Zakath
What are the resource constants defined for the combo boxes? IDC_COMBOBOX1 and IDC_COMBOBOX2?

If so, do something like this:

[code]
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;
}[/code]
December 15, 2004, 3:07 AM
Okee
Nice, it's workin now. Thanks.
December 15, 2004, 4:54 PM

Search