建立以对话框为基础的应用

2014-11-23 20:10:18 · 作者: · 浏览: 18

VC中提供了生成“以对话框为基础的应用”的功能,你所需要选择的是在使用AppWizard的第一步选择“对话框为基础的应用”,如图

VC会生成包含有应用派生类和对话框派生类的代码。在应用类的InitInstance()成员函数中可以看到如下的代码:

BOOL CMy58_s1App::InitInstance()
    
{
    
         CMy58_s1Dlg dlg;
    
         m_pMainWnd = &dlg;
    
         int nResponse = dlg.DoModal();
    
         if (nResponse == IDOK)
    
         {
    
                 // TODO: Place code here to handle when the dialog is
    
                 //  dismissed with OK
    
         }
    
         else if (nResponse == IDCANCEL)
    
         {
    
                 // TODO: Place code here to handle when the dialog is
    
                 //  dismissed with Cancel
    
         }
    
 
    
         return FALSE;
    
}
    

这是产生一个有模式对话框并创建它,在对话框返回后通过返回FALSE来直接退出。在设计时通过编辑对话框资源你可以设计好界面,然后通过ClassWizard映射消息来处理客户的输入,由于前几节已经讲过本节也就不再重复。

同样基于对话框的应用也同样可以使用属性对话框做为界