Dialog Problem
-
Hi Folks i am here with a problem I did the followin things in my SDI VC application(MFC exe with default App wizrad options) 1.Created a Dialog Resource with a ComboBox(Attached a Control Variable to that m_ctrlCombo) ,attached a new class to it ( CTestDlg ). 2.Created object of CTestDlg in view class in OnLButtonDown() [code] void CTestView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CTestDlg dlg; dlg.m_ctrlCombo.AddString("Alpha"); dlg.m_ctrlCombo.AddString("Beta"); dlg.DoModal(); CView::OnLButtonDown(nFlags, point); } [/code] The Problem is that when i run the application and OnLButtonDown() Function is invoked .I get a debug assetion failure * "File: afxwin2.inl Line 735 " when i ignore it two times the Dialog is shown but no string attached to the comboBox Plz help me out Folks to solve this. Thanx in advance.
-
Hi Folks i am here with a problem I did the followin things in my SDI VC application(MFC exe with default App wizrad options) 1.Created a Dialog Resource with a ComboBox(Attached a Control Variable to that m_ctrlCombo) ,attached a new class to it ( CTestDlg ). 2.Created object of CTestDlg in view class in OnLButtonDown() [code] void CTestView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CTestDlg dlg; dlg.m_ctrlCombo.AddString("Alpha"); dlg.m_ctrlCombo.AddString("Beta"); dlg.DoModal(); CView::OnLButtonDown(nFlags, point); } [/code] The Problem is that when i run the application and OnLButtonDown() Function is invoked .I get a debug assetion failure * "File: afxwin2.inl Line 735 " when i ignore it two times the Dialog is shown but no string attached to the comboBox Plz help me out Folks to solve this. Thanx in advance.
jinbabaj wrote: dlg.m_ctrlCombo.AddString("Alpha"); dlg.m_ctrlCombo.AddString("Beta"); This should be in the InitDialog method of the dialog. The assert pops because the dialog is not CREATED, only constructed, and will be created in the DoModal method.
Maximilien Lincourt "Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
-
jinbabaj wrote: dlg.m_ctrlCombo.AddString("Alpha"); dlg.m_ctrlCombo.AddString("Beta"); This should be in the InitDialog method of the dialog. The assert pops because the dialog is not CREATED, only constructed, and will be created in the DoModal method.
Maximilien Lincourt "Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
Yes!Maximilien is right!