关于Create()
我做了一个对话框ID为IDD_ADDSHORTCUTS,又在菜单栏添加了一个按钮,响应按钮的Command函数为 void CMainFrame::OnDrawAddshortcuts()。我想当点击此按钮时弹出我的对话框,代码如下,但为什么什么反应都没有呢?
void CMainFrame::OnDrawAddshortcuts()
{
// TODO: Add your command handler code here
CDialog dlg;
if(!dlg.Create(IDD_ADDSHORTCUTS,this))
AfxMessageBox("Error");
}
另外,我把代码改成如下:
void CMainFrame::OnDrawAddshortcuts()
{
// TODO: Add your command handler code here
CDialog dlg;
if(!dlg.Create(IDD_ADDSHORTCUTS,this))
;
AfxMessageBox("Error");
}
居然能出来!可是我点MessageBox的确定后就连同对话框一起消失了,这是怎么回事呢?
另外,我知道给对话框弄一个类,再用DoModal()可以出来对话框,但没有别的方法了么,create()为什么不行呢?
请大家指教。