要修改VC模式对话框控件属性,必然,最重要的是弄清楚对话框上的控件在何时创建,要在保证创建之后才修改,在网上找到一些资料,提出了修改对话框类的构造函数的方法,但是经测试,不能完成。后来把

 m_ListSet.AddString("属性");

放到对话框类的 OnInitDialog()函数中,响应WM_INITDIALOG消息,顺利执行!

具体原因等毕业设计做完之后去研究。

 

当DoModal被调用后,实际在幕后引起一系列如下的动作:
CDialog::DoModal->CEx06Dialog::OnInitDialog->其它的初始化->CDialog::OnInitDialog->CWnd::UpdateData(FALSE)->CEx06Dialog::DoDataExchange
用户输入数据…
用户单击OK按钮
CEx06Dialog::OnOk->…其它的确认处理…->CDialog::OnOk->CWnd::UpDateData(TURE)->CEx06Dialog::DoDataExchange->CDialog::EndDialog(IDOK)
说明:
1)virtual BOOL OnInitDialog( );
//CDialog::OnInitDialog This member function is called in response to the WM_INITDIALOG message. This message is sent to the dialog box during the Create, CreateIndirect, or DoModal calls, which occur immediately before the dialog box is displayed.
//Override this member function if you need to perform special processing when the dialog box is initialized.

2)BOOL UpdateData( BOOL bSaveAndValidate = TRUE );
//CWnd::UpdateData :Call this member function to initialize data in a dialog box, or to retrieve and validate dialog data.
//bSaveAndValidate:Flag that indicates whether dialog box is being initialized (FALSE) or data is being retrieved (TRUE).
//By default UpdateData(TRUE) is called in the default CDialog::OnOK handler and UpdateData(FALSE) is called in the default CDialog::OnInitDialog.

3)virtual void DoDataExchange( CDataExchange* pDX );
//CWnd::DoDataExchange Called by the framework to exchange and validate dialog data.
//Never call this function (DoDataExchange) directly. It is called by the UpdateData member function.
//Call UpdateData to initialize a dialog box’s controls or retrieve data from a dialog box.

4)void EndDialog( int nResult );
//CDialog::EndDialog makes the dialog box invisible but does not destroy it.
//Call this member function to terminate a modal dialog box. This member function returns nResu

Tagged with:
 

2 Responses to VC模式对话框控件属性的修改

  1. 北宫赫 says:

    搞笑啊!不过我告诉你,那个打靶成绩当时是看得到的,我打了一个7环和一个9环,不过大多数人都是瞄着别人靶子打的。我当时也不知道哪个靶子是我的,所以只好把附近几个都打了一下。

  2. subject says:

    两星期没上网了,没想到你居然整了这么长篇幅的回忆录,继续啊

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>