1. Firstly, Create a new project which is based on SDI.
2. Add a new dialog to resource.
3. Add class to the added dialog (should be based on CDialog class) (ex. CMyDlg)
4. Add a member function "BOOL Create(Cwnd* pParentWnd); " in CMyDlg class.
5. type below codes for the member function in .cpp file of the above class,
BOOL CMyDlg::Create(CWnd* pParentWnd)
{
return CDialog::Create(IDD, pParentWnd);
}
6. include "CMyDlg" in main frame class (Or View class)
7. declare the added class' instance (e.g., CMyDlg *dlg;)
8. Lastly, in .cpp file of Main frame class (or view class), type below codes in OnCreate (if there is no OnCreate, add message function) ,
dlg = new CMyDlg;
dlg->Create(this);
dlg->ShowWindow(SW_SHOW);
dlg->MoveWindow(0,0,1024,64);
Additionally, if menu buttons (or event handler) are used for create the dialog,
refer to below functions:
bool CMFC_TESTView::CreateChildDlg(void)
{
if(dlg
!= NULL) return 0;
dlg = new CMyDlg;
if(dlg->GetSafeHwnd() ==0)
{
if(!dlg->Create(this))
return 0;
else {dlg->ShowWindow(SW_SHOW);
//dlg->MoveWindow(0,0,1024,64);
}
}
return
TRUE;
}
bool CMFC_TESTView::DestroyChildDlg(void)
{
if(dlg != NULL)
if(!dlg->DestroyWindow()) return
FALSE;
dlg =NULL;
return
TRUE;
}
** This post is written by courtesy of : http://blog.daum.net/_blog/BlogTypeView.do?blogid=0WCjO&articleno=6
댓글 없음:
댓글 쓰기