Message ing in the dialog box

Source: Internet
Author: User

 

One advantage of using the dialog box is that you can useClassWizard maps messages generated by various controls in the dialog box. ClassWizrd can list messages available to various controls and automatically generate code. This section uses an example to illustrate how to map subwindow messages in the dialog box and how to initialize subwindows in the dialog box.

First, an edit dialog box is generated,,

Controls andThe ID number is shown in the following table:

ID

Type

IDC_RADIO_TEST_1

Circle button

IDC_RADIO_TEST_2

Circle button

IDC_BUTTON_TEST

Button

IDC_CHECK_TEST

Check button

IDC_TREE_TEST

Tree Control

IDC_LIST_CTRL

List Ctrl

IDC_TAB_CTRL

Tab Ctrl

IDC_LIST_TEST

List box

IDC_COMBO_TEST

Combo box

IDC_EDIT_TEST

Input box

First, we needThe OnInitDialog () function initializes each control. Here we use CWnd * GetDlgItem (int nID) to obtain the sub-window pointer through the ID number. (Similar functions include UINT GetDlgItemInt (int nID, BOOL * lpTrans = NULL, BOOL bSigned = TRUE). Use the ID number to obtain the number entered in the subwindow. int GetDlgItemText (int nID, CString & rString) use the ID to obtain the text entered in the subwindow ). The Code is as follows:

BOOL CMy54_s1Dlg: OnInitDialog ()
  
{
  
CDialog: OnInitDialog ();
  
/* Add initialization Code */
  
// Initialize the input box
  
(CEdit *) GetDlgItem (IDC_EDIT_TEST)-> SetWindowText ("this is a edit box ");
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.