Link to home
Start Free TrialLog in
Avatar of jrmcg
jrmcg

asked on

Initializing ComboBox inside CDialogBar

I am trying to initialize a CComboBox control in a CDialogBar created with the Resource editor.  I attach the tool bar to a Child Window in an MDI app.  I want to fill the contents of the CboBox when the tool bar is loaded.

This is how I am trying to do it...
-- inside   CMyChildFrm::OnCreate(....)
CComboBox* pCombo;

pCombo = (CComboBox*)GetDlgItem(IDC_COMBOBOX);
pCombo->AddString("SomeString");

I am sure I am just overlooking something, what am I doing wrong???

The assertion error occurs when the pCombo->AddString("") is attempted.  It is an Access Violation.

What is the proper casting and access method?

Thanks,
J.R.
ASKER CERTIFIED SOLUTION
Avatar of plaroche
plaroche

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plaroche
plaroche

Sorry, in my answer pBar will be invalid. What I meant was that pBar should be a pointer to your previously created dialogbar object.
Avatar of jrmcg

ASKER

That did it.  Thanks.  I knew it would be something simple.

J.R.