非模态对话框是怎样创建并传递消息的啊
非模态对话框是怎样创建并传递消息的啊,我是初学者,希望高人给予解答,最好举一个小例子,不胜感激
调用CDialog::Create 成员函数用资源中的对话框模板一个非模态对话框
BOOL Create( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );
BOOL Create( UINT nIDTemplate, CWnd* pParentWnd = NULL );
如果要求父窗口产生时显示对话框,则要求将对话框模板选用 WS_VISIBLE ,或者调用ShowWindow
CMyDialog* pDialog;
void CMyWnd::OnSomeAction()
{
//pDialog initialized to NULL in the constructor of CMyWnd class
pDialog = new CMyDialog();
//Check if new succeeded and we got a valid pointer to a dialog object
if(pDialog != NULL)
{
BOOL ret = pDialog->Create(IDD_MYDIALOG,this);
if(!ret) //Create failed.
AfxMessageBox("Error creating Dialog");
pDialog->ShowWindow(SW_SHOW);
}
else
AfxMessageBox("Error Creating Dialog Object");
}