|
-
January 20th, 2013, 05:42 AM
#9
Re: How to call Dialog window (formed as resource) from a .DLL
 Originally Posted by Pavel_47
Below is extract from new .DLL application class, which doesn't work (resource IDD_FORMVIEW, associated with class CPixie3_DLG in't displayed).
It's shorter, than previous one, as CPixie3_DLG class is already created.
Code:
BOOL CPixie3_GUIApp::InitInstance()
{
CWinApp::InitInstance();
m_pMainWnd = new CPixie3_DLG();
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Where is my mistake ?
Well, except the fact that you go with technology you are not familiar with... These are two typical snippets for dialogs:
1.
Code:
BOOL CPixie3_GUIApp::InitInstance()
{
CWinApp::InitInstance();
CPixie3_DLG * pDlg = new CPixie3_DLG();
m_pMainWnd = pDlg;
pDlg->Create(IDD_FORMVIEW);
pDlg->ShowWindow(SW_SHOW);
pDlg->UpdateWindow();
return TRUE;
}
The code implies the dialog class is adapted to be destroyed explicitly by calling DestroyWindow(), but not CDialog::OnCancel() or CDialog::OnOK(). And C++ object is deleted explicitly in PostNcDestroy() handler.
2.
Code:
BOOL CPixie3_GUIApp::InitInstance()
{
CWinApp::InitInstance();
CPixie3_DLG dlg;
dlg.DoModal();
return FALSE;
}
The code implies the dialog is destroyed by OnOK or OnCancel, and C++ object is destroyed automatically on leaving InitInstance scope..
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|