1. It is pretty fast and convinient to create a dialog based application from VC2005's
project wizard. But Once you created it, it is very difficult for you to customize it.
For example, modifying a dialog based project into a multi-document one requires much more
efforts than create it from project wizard directly.
2. If, after creating a dialog based application, you want to cutomize it, say changing the
languages, changing some properties of the items. A dialog sceleton contains a label,
instance of CStatic, two buttons, an about dialog and a main dialog(that dialog which will be
showed). Chances are that you want to change the titles or the contents of the label. To do that,
you have to get the instances of the items. Then you can change their properties through their
member functions. To get the instances, you must provide their ids, which are their identifications.
Those items are contained by the main dialog, which is the parent of those items. You can get the
child items through their ids. Here main dialog is the parent and its label and its buttons are
child items. Function:
GetDlgItem(const int id);
are used to retrieve child items from parent instance.
Here to get the label, the two buttons from a typical dialog based applicaiton.
button_cancel = (CButton *) GetDlgItem(IDCANCEL); // you should change IDCANCEL to your id
button_ok = (CButton *) GetDlgItem(IDOK);
label = (CStatic *) GetDlgItem(IDC_STATIC1);
Then you can set properties for those items, e.g. change the title:
label->SetWindowText(label_tip); // label_tip is the contents you want
button_ok->SetWindowText(ok_title); // title for button OK
button_cancel->SetWindowText(cancel_title);
how to get internal items from a dialog created from wizard of VC2005
本文介绍使用Visual C++ 2005创建对话框基础的应用程序,并详细讲解了如何通过修改对话框中的元素如标签和按钮来定制应用程序。文章提供了具体的步骤和代码示例,帮助读者理解如何获取并设置对话框中各组件的属性。

被折叠的 条评论
为什么被折叠?



