CComboBox dropdown does not work
Posted on 2003-10-30
I created a control. Based upon CComboBox.
class C_ComboBox : public CComboBox
rest of this code no shown for brevity.
Then I use it in a dialog as follows.
C_ComboBox * m_cComboS;
m_cComboS = (C_ComboBox*)new C_ComboBox;
m_cComboS->Create( WS_CHILD|WS_VISIBLE|CBS_SORT| WS_TABSTOP|WS_VSCROLL|CBS_DROPDOWN, CRect(131,96,376,92), this, IDC_MY_COMBO);
That works and I can add strings.
CString test = "1234567890";
for ( int i=0; i<25; i++)
int NumItems = m_cComboS->GetCount();
NumItems is equal to 25. So I assume 25 strings have been added.
Now comes the problem. I can’t get the drop down to show.
When I click the “down arrow button” next to the edit field I expected to see the list of string that got added.
That does not work.
If I handle the ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropdown)
int Drop = this->GetDroppedState();
Drop is always 0 and ShowDropDown(TRUE); gets called until a stack overflow happens.
What did I do wrong…
If I use a regular CComboBox directly in the dialog and set the dropdown list height in the resource editor it works just fine.
I Created the C_ComboBox so that I could get to the Pop-up menu feature.