how to get internal items from a dialog created from wizard of VC2005

本文介绍使用Visual C++ 2005创建对话框基础的应用程序,并详细讲解了如何通过修改对话框中的元素如标签和按钮来定制应用程序。文章提供了具体的步骤和代码示例,帮助读者理解如何获取并设置对话框中各组件的属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值