Creating a combobox & checkbox dynamically
-
Hi, I have pasted a peice of code that I use to create the combo box dynamically, but found that it draws a edit box, not a combo box. CComboBox m_schemaCombo; m_schemaCombo.CreateEx( WS_EX_CLIENTEDGE, _T("COMBOBOX"), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER, CRect(row3, frameTop + 3 * topBottomOffset + buttonHeight3, editBoxWidth, frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2), this, IDC_SCHEMA_COMBO, 0 ); m_schemaCombo.SetFont( GetFont() ); Very sceptical about the 2nd argument of CreateEx. Can anybody help me out? Also, please let me know the way to create a checkbox also. Thanks, Prashant
-
Hi, I have pasted a peice of code that I use to create the combo box dynamically, but found that it draws a edit box, not a combo box. CComboBox m_schemaCombo; m_schemaCombo.CreateEx( WS_EX_CLIENTEDGE, _T("COMBOBOX"), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER, CRect(row3, frameTop + 3 * topBottomOffset + buttonHeight3, editBoxWidth, frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2), this, IDC_SCHEMA_COMBO, 0 ); m_schemaCombo.SetFont( GetFont() ); Very sceptical about the 2nd argument of CreateEx. Can anybody help me out? Also, please let me know the way to create a checkbox also. Thanks, Prashant
-
Try using the CComboboxEx class instead of the Combobox class. I'm not very sure but I hope this is useful Dipeka.A.J
-
Hi, I have pasted a peice of code that I use to create the combo box dynamically, but found that it draws a edit box, not a combo box. CComboBox m_schemaCombo; m_schemaCombo.CreateEx( WS_EX_CLIENTEDGE, _T("COMBOBOX"), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER, CRect(row3, frameTop + 3 * topBottomOffset + buttonHeight3, editBoxWidth, frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2), this, IDC_SCHEMA_COMBO, 0 ); m_schemaCombo.SetFont( GetFont() ); Very sceptical about the 2nd argument of CreateEx. Can anybody help me out? Also, please let me know the way to create a checkbox also. Thanks, Prashant
-
Hi, I have pasted a peice of code that I use to create the combo box dynamically, but found that it draws a edit box, not a combo box. CComboBox m_schemaCombo; m_schemaCombo.CreateEx( WS_EX_CLIENTEDGE, _T("COMBOBOX"), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER, CRect(row3, frameTop + 3 * topBottomOffset + buttonHeight3, editBoxWidth, frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2), this, IDC_SCHEMA_COMBO, 0 ); m_schemaCombo.SetFont( GetFont() ); Very sceptical about the 2nd argument of CreateEx. Can anybody help me out? Also, please let me know the way to create a checkbox also. Thanks, Prashant
The answer is quite simple. What you are doing here is calling
CWnd::CreateEx
, that allows you to create child windows. However, there is a function callCComboBox::Create
that will create a combo box control and attach it to theCComboBox
object. The calling convention forCreate
is a bit different, as you only need to supply the standard flags, rectangle, pointer to parentCWnd
and the ID. This call doesn't allow you to specify extended window flags. But you can useGetExStyle
, a bit mask andSetWindowLong
to set the client edge extended style. Another reason why it creates an edit box might be because of the ES_NUMBER flag. This flag is meant for edit controls, not comboboxes. All combobox flags start with CBS_ prefix. Try removing it and see what happens. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible. -
Hi, I have pasted a peice of code that I use to create the combo box dynamically, but found that it draws a edit box, not a combo box. CComboBox m_schemaCombo; m_schemaCombo.CreateEx( WS_EX_CLIENTEDGE, _T("COMBOBOX"), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | ES_NUMBER, CRect(row3, frameTop + 3 * topBottomOffset + buttonHeight3, editBoxWidth, frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2), this, IDC_SCHEMA_COMBO, 0 ); m_schemaCombo.SetFont( GetFont() ); Very sceptical about the 2nd argument of CreateEx. Can anybody help me out? Also, please let me know the way to create a checkbox also. Thanks, Prashant
How about:
CComboBox m_schemaCombo;
m_schemaCombo.Create(WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
CRect(row3,
frameTop + 3 * topBottomOffset + buttonHeight3,
editBoxWidth,
frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2),
this, IDC_SCHEMA_COMBO);
m_schemaCombo.SetFont(GetFont());
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
How about:
CComboBox m_schemaCombo;
m_schemaCombo.Create(WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
CRect(row3,
frameTop + 3 * topBottomOffset + buttonHeight3,
editBoxWidth,
frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2),
this, IDC_SCHEMA_COMBO);
m_schemaCombo.SetFont(GetFont());
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen