Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals


Alternatively, you can first create an identifier in the String Table. We saw how to do this
in Lesson 3. You can also create an identifier using the Resource Symbols dialog box.
Then use that identifier for your control. Here is an example:

BOOL CBordersDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
CWnd *btnDismiss = new CWnd;
btnDismiss->Create("BUTTON", "&Dismiss", WS_CHILD | WS_VISIBLE,
CRect(12, 68, 128, 120), this, IDN_DISMISS);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

Practical Learning: Completing the Control



  1. To create an identifier, in the Resource View, right-click the name of the appication,
    (MSVC 6) Controls resources or (MSVC 7) Controls, and click Resource Symbols...

  2. In the Resource Symbols dialog box, click the New... button

  3. Set the Name to IDC_PANEL

  4. Click OK and click Close

  5. On the dialog box, click the Custom control to select it. On the Properties window,
    click the arrow of the ID combo box and select IDC_PANEL

  6. Test the application and return to MSVC

Free download pdf