On
the View menu, click ClassWizard.
The MFC ClassWizard
dialog box appears, click the Message
Maps tab.
In
the Class name box, select the
class CAboutDlg.
In
the Object IDs list, select the IDD_ABOUTBOX.
In
the Messages list, select the WM_INITDIALOG.
Click
Add Function.
The
Add Member Function dialog
box appears, click OK.
To accept the default Member function
name - OnInitDialog
display(or rename
it) and then click OK.
The new item message - OnInitDialog......
ON_WM_INITDIALOG appearing
in the Member functions
list.
ClassWizard makes changes to TestVC0Dlg.cpp
file after you’ve added the member
function. Examine these changes ...
TestVC0Dlg.cpp file - the new Text Code
is red.
// TestVC0Dlg.cpp
: implementation file
//
#include "stdafx.h"
#include "TestVC0.h"
#include "TestVC0Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] =
__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App
About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CString m_edsource;
//}}AFX_DATA
// ClassWizard generated virtual
function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange*
pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual
BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
m_edsource = _T("");
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange*
pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Text(pDX, IDC_EDSOURCE,
m_edsource);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,
CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestVC0Dlg dialog
...................................................................................................................................................
...................................................................................................................................................
...
BOOL
CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization
here
return TRUE; // return TRUE
unless you set the focus to a
control
// EXCEPTION: OCX Property Pages
should return FALSE
} |
|