对话框建立相关问题

1.对话框资源(CTestDlg).
2.对资源的操作是对相应的类进行的.
3.The CDialog class is the base class used for displaying dialog boxes on the screen. Dialog boxes are of two types: modal and modeless. A modal dialog box must be closed by the user before the application continues. A modeless dialog box allows the user to display the dialog box and return to another task without canceling or removing the dialog box.
4.在对话框构造函数中的IDD是对话框头文件中有定义.
<TestDlg.cpp>
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/): CDialog(CTestDlg::IDD, pParent)//这里
<TestDlg.h>
class CTestDlg : public CDialog
{
// Construction
public:
 CTestDlg(CWnd* pParent = NULL);   // standard constructor
// Dialog Data
 //{{AFX_DATA(CTestDlg)
 enum { IDD = IDD_DIALOG1 };//这里
5.对菜单项的{命令响应}放到CMyboleView中完成.------对这句话理解
6.对话框的建立
modal:
 CTestDlg dlg;
 dlg.DoModal();//程序暂停执行,直到modal对话框销毁.
 /**
 An int value that specifies the value of the nResult parameter that was passed to the CDialog::EndDialog member function, which is used to close the dialog box. The return value is –1 if the function could not create the dialog box, or IDABORT if some other error occurred.
  */
modeless:
 public://定义成员变量
 CTestDlg Dlg;

 Dlg.Create(IDD_DIALOG1,this);
 Dlg.ShowWindow(SW_SHOW);

 /************************************/

 CTestDlg *pDlg=new CTestDlg();//定义指针
 pDlg->Create(IDD_DIALOG1,this);
 pDlg->ShowWindow(SW_SHOW);
 /**
 当modeless的Dlg为局部变量时,因为modeless对话框出现时程序不暂停执行,所以Dlg生命周期是创建后立即销毁,所以看不到.
 解决方法:
  1.成员变量:用
  2.指针:问题是定义的指针变量是局部变量,当生命周期结束时,保存的内在地址也就丢失了.可以变成成员变量,在析构函数中用delete释放指针.
  3.Remarks
Called when the user clicks the OK button (the button with an ID of IDOK).
Override this member function to perform the OK button action. If the dialog box includes automatic data validation and exchange, the default implementation of this member function validates the dialog-box data and updates the appropriate variables in your application.
If you implement the OK button in a modeless dialog box, you must override the OnOK member function and call DestroyWindow from within it. Don’t call the base-class member function, because it calls EndDialog, which makes the dialog box invisible but does not destroy it. 
  */ 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值