The first time I used Win32 to write code, I summarized the use of the combo box control in the Code:
1. Use sendmessage to send messages to the window. Perform basic operations on the combo box, such as adding data, deleting data, and obtaining the value of the selected item. For details, see:
Http://blog.csdn.net/qiurisuixiang/article/details/6746234
2. To make the combo box control visible or invisible, use the enablkewindow function:
Enablewindow (hcombo, true );
Enablewindow (hcombo, false );
3. Respond to the notification message of the combo box. For example, if a different item in the combo box is selected, the cbn_selchange message is returned.
Msdn explanation:
Cbn_selchange notification
The cbn_selchange notification message is sent when the user changes the current selection in the list box of a combo box. The user can change the selection by clicking
In the list box or by using the arrow keys. The parent window of the combo box contains es this notification in the form of awm_command message with cbn_selchange in the high-order word
Of the wparam parameter.
Syntax
CBN_SELCHANGE WPARAM wParam LPARAM lParam;
Parameters
-
Wparam
-
The low-order word specifies the control identifier of the combo box.
The high-order word specifies the notification message.
-
Lparam
-
Handle to the combo box.
Process message code:
Lresult callback wndproc (hwnd, uint message, wparam, lparam)
{
Int wmid, wmevent;
Switch (Message)
{
Case wm_command:
-
// Low-order word specifies the control identifier of the combo box.
Wmid = loword (wparam );
-
// High-order word specifies the notification message.
Wmevent = hiword (wparam );
// Select the analysis menu:
Switch (wmevent)
{
Case cbn_selchange:
If (wmid = idc_combo_mode) // determines which combo box is selected
{
......
}
Break;
}
Break;
Case wm_destroy:
Postquitmessage (0 );
Break;
// Although the dialog box procedure is similar to a window procedure,
// It must not call the defwindowproc function to process unwanted messages
// Default:
// Return defwindowproc (hwnd, message, wparam, lparam );
}
Return 0;
}