how to get internal items from a dialog created from wizard of VC2005
2009-12-03 19:46
453 查看
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.
Then you can set properties for those items, e.g. change the title:
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 a notification from Linux when the set of network interfaces changes
- How to get the Values of Selected Row from a Gridview using ASP.NET
- How to get the data from a cell when I click on the GridButtonColumn of the same row
- How to Display a SharePoint Dialog from Ribbon Button and Get Selected Item Context
- How to get the DOM of a WebBrowser control from a window handle (VB6)
- How to get rid of `deprecated conversion from string constant to 'char*'` warnings in GCC?
- How to Get Rid of /wordpress/ From your WordPress Site URL
- [RxJS] How To get the results of two HTTP requests made in sequence
- JSP URI/URL - How to get the request URI, URL, and Context from a JSP
- How to get HTML code of a WebElement in Selenium
- [GuanRui]How to open Path browse dialog in VBA of ArcGIS Desktop ?
- How to get version of Informix JDBC Driver
- How to get source code from APK
- how to get domain user info from AD in C#
- how to get charset from string and file
- How to Display Image In Picturebox in VC++ from Iplimage and Mat
- how can i get [5, 7, 13, 2] to go to [5*0, 7*1, 13*2, 2*3] then get the sum of this array.
- How to change the property of a control from a flowlayoutpanel?
- How to Get the Frequency Table of a Categorical Variable as a Data Frame in R
- How to get simple dispatch from this.props using connect w/ Redux?