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