views:

169

answers:

1

I'm trying to create a simple ATL control based on a ComboBox under VS2008. So, I create a new ATL Project using the ATL Project Wizard, then add an ATL Control to the project using the ATL Control Wizard. I use all of the default settings except that I tell the wizard to base my control on ComboBox. The wizard does its thing and generates the control.

When I build this control and put it in a test container (e.g. the old ActiveX Control Test Container) it doesn't look the way I'd hoped it would. The combobox is being created with the wizard-generated code:

m_ctlComboBox.Create(m_hWnd, rc);

What I really want is a combobox with the dropdown style (preferably one which draws using the current OS theme so that the control doesn't look out of place). To this end I've tried changing the call to Create to specify CBS_DROPDOWN, like so:

m_ctlComboBox.Create(m_hWnd, rc, NULL, CBS_DROPDOWN);

and I've also tried calling ModifyStyle to add in the CBS_DROPDOWN style:

m_ctlComboBox.Create(m_hWnd, rc);
m_ctlComboBox.ModifyStyle(0, CBS_DROPDOWN);

But neither of these minor changes seem to work.

I'm a complete novice with ATL control creation so apologies in advance if this is a rookie error, but can anyone explain - as simply as possible - what mistake(s) I'm making here?

+1  A: 

Understanding Window Traits

Sheng Jiang 蒋晟
Thanks. Using traits did indeed create the control style I was looking for.
WalderFrey