modeless dialog error
-
tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }
-
tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }
NoName II wrote:
m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error
in the constructor it self the window is created. So why u gonne call Create again...? And if u stick to the above code then code like this if( m_dlg->m_hWnd ) { m_dlg->DestroyWindow(); } m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL);
nave
-
tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }
NoName II wrote:
//: CDialog(CMyDlg::IDD, pParent)
You should remove this code from your constructor. because it will create a dialog with the IDD (resource ID) you are passing. that is why it failed. see MSDN to know how to create modeless dialog?[^] You can see the following in the documentation... that For a modeless dialog box, you must provide your own public constructor in your dialog class.
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
-
NoName II wrote:
//: CDialog(CMyDlg::IDD, pParent)
You should remove this code from your constructor. because it will create a dialog with the IDD (resource ID) you are passing. that is why it failed. see MSDN to know how to create modeless dialog?[^] You can see the following in the documentation... that For a modeless dialog box, you must provide your own public constructor in your dialog class.
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
Sarath. wrote:
because it will create a dialog with the IDD (resource ID) you are passing
i don't agree see the code inside the constructor.
CDialog::CDialog(UINT nIDTemplate, CWnd* pParentWnd) { AFX_ZERO_INIT_OBJECT(CWnd); m_pParentWnd = pParentWnd; m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate); m_nIDHelp = nIDTemplate; }
is only sets the member varaiable.Wont create the dialognave
-
Sarath. wrote:
because it will create a dialog with the IDD (resource ID) you are passing
i don't agree see the code inside the constructor.
CDialog::CDialog(UINT nIDTemplate, CWnd* pParentWnd) { AFX_ZERO_INIT_OBJECT(CWnd); m_pParentWnd = pParentWnd; m_lpszTemplateName = MAKEINTRESOURCE(nIDTemplate); m_nIDHelp = nIDTemplate; }
is only sets the member varaiable.Wont create the dialognave
yes once I had went through the code... for the ease of undestanding I explained it that manner. when creating a modal dialog, the error occurs at module state handling. The function get called twice. first on the ctor and Create function Anyway I dont know more about the same. It would nice informative if you share how a modal dialog asserts on the above scenario -- modified at 6:48 Monday 31st July, 2006
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
-
tryin to create modeless dialog... m_dlg->Create(CMyDlg::IDD, &m_tabctrl/*CTabCtrl*/);// ASSERT(pWnd->m_hWnd == NULL); // debug error constructor: CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) //: CDialog(CMyDlg::IDD, pParent) { this->Create(CMyDlg::IDD, pParent); this->ShowWindow(SW_NORMAL); }
Hope I understood your question
CMyDlg *mydialog; mydialog=new CMyDlg(this); CMyDlg::CMyDlg(CWnd* pParent) : CDialog(CMyDlg::IDD, pParent) { Create(pParent); ShowWindow(SW_NORMAL); }
_**
**_
WhiteSky
-
yes once I had went through the code... for the ease of undestanding I explained it that manner. when creating a modal dialog, the error occurs at module state handling. The function get called twice. first on the ctor and Create function Anyway I dont know more about the same. It would nice informative if you share how a modal dialog asserts on the above scenario -- modified at 6:48 Monday 31st July, 2006
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
check the code he posted. in the constructor itself he creates the dialog. I.e CMyDlg dlg; // Dialog is created in this line itself. then he calls dlg.Create(...) the dialog is already created, hence Assertion fails will come and most probably from the function void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { .......... ASSERT(pWnd->m_hWnd == NULL); // only do once ........... }
nave
-
check the code he posted. in the constructor itself he creates the dialog. I.e CMyDlg dlg; // Dialog is created in this line itself. then he calls dlg.Create(...) the dialog is already created, hence Assertion fails will come and most probably from the function void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { .......... ASSERT(pWnd->m_hWnd == NULL); // only do once ........... }
nave
So it's not part of CDialog. it's part of CWnd right? then how the creation with template name specified occurs?
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
-
So it's not part of CDialog. it's part of CWnd right? then how the creation with template name specified occurs?
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
-
NoName II wrote:
//: CDialog(CMyDlg::IDD, pParent)
You should remove this code from your constructor. because it will create a dialog with the IDD (resource ID) you are passing. that is why it failed. see MSDN to know how to create modeless dialog?[^] You can see the following in the documentation... that For a modeless dialog box, you must provide your own public constructor in your dialog class.
SaRath.
_"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
Sarath. wrote:
You should remove this code from your constructor.
That code is fine. It was the extra
Create()
call that was the problem. Note the assertion indicated exactly what the problem was (i.e., the window handle was non-NULL
).
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb