pankaj sharma103086


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


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


Re: Visual C++ General Assertion failed

Maksim Libenson


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.


Re: Visual C++ General Assertion failed


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

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).