How can I detect a change in the ComboBox?
For example: so when the first option of the combobox (index=0) is selected, I could disable some other control.
I would like to do that in simple API, without any MFC.
Thank you.
Printable View
How can I detect a change in the ComboBox?
For example: so when the first option of the combobox (index=0) is selected, I could disable some other control.
I would like to do that in simple API, without any MFC.
Thank you.
The combobox will send you a notification message:
This is from a program I am currently working on. It will launch the function ChangeAvailableBitrates() when the combo box IDC_SAMPFREQ2 has been closed (i.e. the user made a new selection).Code:case WM_COMMAND:
{
switch(HIWORD(wParam))
{
case CBN_CLOSEUP:
switch(LOWORD(wParam))
{
case IDC_SAMPFREQ2:
ChangeAvailableBitrates(hBitrates, false);
}
}
so when a user closed the combobox, he probably made a new selection, so then I will read the combobox, and know what to do...
But I could just do:
Thanks man.Code:if ((LOWORD(wParam)==ID_MY_COMBO)&&(HIWORD(wParam)==CBN_CLOSEUP))
/* do something */
yeah just send the something like the CB_GETCURSEL message, which will return the zero-based index of the item currently selected, then do your thang.
Thanks a million
No probs. :)
Just one more thing...
How did you know it's a HIWORD(wParam)...
Because I just looked up the CBN_CLOSEUP in the msdn, and it didn't say anything about hiword.
butCode:CBN_CLOSEUP
idComboBox = (int) LOWORD(wParam); // identifier of combo box
hwndComboBox = (HWND) lParam; // handle of combo box
CBN_CLOSEUP is a notification message so it is in the high word of the wParam of WM_COMMAND. :)Code:WM_COMMAND
wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam); // item, control, or accelerator identifier
hwndCtl = (HWND) lParam; // handle of control
always the same structure... LOWORD is CONTROL ID
and HIWORD is notification.
Thanks for making it clear to me.
Here is the entire reference for Combo Boxes (if you aren't already using it).
gg