pankaj sharma103086

hi

I have created a MFC dialog based application , on this dialog a button is present , when i click on this button another dialog box(NewDlg) appears which i have created by using "insert dialog" in resource View,on this dilaog box(NewDlg) i have a combobox,Now i want to add values in this combobox , so i have created a member variable(m_Combo1) for this combobox of type CComboBox using MFC ClassWizard .Now the problem is where should i put the line

m_Combo1.AddString("VC++");

if i put this line in OnInitDialog() (of NewDlg.cpp) then i get
"Debug Assertion Failed "
File : afxwin2.inl
Line:735

Regards
Pankaj






Re: Visual C++ General Assertion failed

Maksim Libenson

Hi,

I would put it in the handler of the WM_CREATE or WM_SHOW message.

You can get them using wizard, by going in to resource view, selecting second dialog template and choosing "Messages" button in the toolbar strip there.

Max






Re: Visual C++ General Assertion failed

dead1

i had the same problem and setting the code in wm_create or wm_show didn't help.

It turned out to be that i used a to small char array to convert a integer.

So changing the size of this 1 did the trick.





Re: Visual C++ General Assertion failed

Luc Leroy

Hi,
The fact it is done at INIT, SHOW or CREATE is not the problem.

You need to have the combobox control created first, otherwise the hwnd member is NULL, that is the cause of the assertion you meet.
Call CComboBox::Create() in the OnInitDialog() method (safer than at creation time).