How do I get a handle to the listbox portion of a ComboBox?
Printable View
How do I get a handle to the listbox portion of a ComboBox?
The ComboBox is only shown when the ComboBox is clicked. Therefor, you need to catch the CBN_DROPDOWN notification message. Then use FindWindowEx() to get the handle of the control. I believe the class of the control is ComboListBox.
I tried to do that but FindWindowEx() returns NULL..
I remember seeing in MSDN the class was ComboLBox.
I tried ComboListBox too, but that didnt seem to work either...
here is my FindWindowEx() call in the handler for the CBN_DROPDOWN notification message.
HWND test = FindWindowEx ( hWnd, NULL, "ComboLBox", NULL );
Where hWnd is the HWND of the combobox itself.
What is the listbox in a combobox actually? If that is the box in the combobox then you can use "ChildWindowFromPoint" with the x,y as 2,2 or a little more.
Quote:
GetComboBoxInfo
The GetComboBoxInfo function retrieves information about the specified combo box.
BOOL GetComboBoxInfo(
HWND hwndCombo, // handle to combo box
PCOMBOBOXINFO pcbi // combo box information
);
Parameters
hwndCombo
[in] Handle to the combo box.
pcbi
[out] Pointer to a COMBOBOXINFO structure that receives the information.
Quote:
COMBOBOXINFO
The COMBOBOXINFO structure contains combo box status information.
typedef struct tagCOMBOBOXINFO {
DWORD cbSize;
RECT rcItem;
RECT rcButton;
DWORD stateButton;
HWND hwndCombo;
HWND hwndItem;
HWND hwndList;
} COMBOBOXINFO, *PCOMBOBOXINFO, *LPCOMBOBOXINFO;
Members
cbSize
Specifies the size, in bytes, of the structure.
rcItem
A RECT structure that specifies the coordinates of the edit box.
rcButton
A RECT structure that specifies the coordinates of the button that contains the drop-down arrow.
stateButton
Specifies the combo box button state. This parameter can be one of the following values. Value Meaning
0 The button exists and is not pressed.
STATE_SYSTEM_INVISIBLE There is no button.
STATE_SYSTEM_PRESSED The button is pressed.
hwndCombo
Handle to the combo box.
hwndItem
Handle to the edit box.
hwndList
Handle to the drop-down list.