- ClassWizard,
Add the member function - (object ID:
IDC_ABOUT ).
- 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 CTestVC0Dlg.
- In the Object
IDs list, select the IDC_ABOUT.
- In the Messages
list, select the BN_CLICKED.
- Click
Add Function.
- The Add
Member Function dialog
box appears, click OK.
To accept
the default Member function name
- OnAbout display(or
rename it) and then click OK.
The new item message - OnAbout......
ON_IDC_ABOUT:BN_CLICKED appearing
in the Member functions
list.
ClassWizard makes changes to TestVC0Dlg.h
and TestVC0Dlg.cpp
files after you’ve added the
member function. Examine these
changes ...
TestVC0Dlg.h file - the new
Text Code is red.
//
TestVC0Dlg.h : header
file
//
...
...................................................................................................................................................
...................................................................................................................................................
// Generated message map
functions
//{{AFX_MSG(CTestVC0Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT
nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR
OnQueryDragIcon();
afx_msg
void OnRecordFirst();
afx_msg void OnRecordPrev();
afx_msg void OnRecordNext();
afx_msg void OnRecordLast();
afx_msg void OnAbout();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
...................................................................................................................................................
...................................................................................................................................................
... |
TestVC0Dlg.cpp
file - the new
Text Code is red.
//
TestVC0Dlg.cpp :
implementation file
//
#include "stdafx.h"
#include "TestVC0.h"
#include "TestVC0Dlg.h"
...
...................................................................................................................................................
...................................................................................................................................................
void CTestVC0Dlg::DoDataExchange(CDataExchange*
pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestVC0Dlg)
DDX_Text(pDX, IDC_BOOK,
m_book);
DDX_Text(pDX,
IDC_CHAPTER, m_chapter);
DDX_Text(pDX, IDC_TITLE,
m_title);
DDX_Text(pDX, IDC_VERSE,
m_verse);
DDX_Text(pDX,
IDC_TEXTDATA, m_textdata);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestVC0Dlg,
CDialog)
//{{AFX_MSG_MAP(CTestVC0Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_RECORD_FIRST,
OnRecordFirst)
ON_BN_CLICKED(IDC_RECORD_PREV,
OnRecordPrev)
ON_BN_CLICKED(IDC_RECORD_NEXT,
OnRecordNext)
ON_BN_CLICKED(IDC_RECORD_LAST,
OnRecordLast)
ON_BN_CLICKED(IDC_ABOUT,
OnAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
...
...................................................................................................................................................
...................................................................................................................................................
void
CTestVC0Dlg::OnAbout()
{
// TODO: Add your control
notification handler code
here
} |
|
- ClassWizard,
Edit the Code - (function
OnAbout ).
- In the ClassWizard
dialog box, select the Message
Maps tab and in the Class
Name box,
select the class CTestVC0Dlg.
- In the Member
Functions list, select
the function name - OnAbout:
Choose Edit Code
-or-
Double-click the function name.
The insertion point moves to the
function in theTestVC0Dlg.cpp
file. Edit
the Text Code,
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"
...
...................................................................................................................................................
...................................................................................................................................................
void
CTestVC0Dlg::OnAbout()
{
CAboutDlg
dlgAbout;
dlgAbout.DoModal();
// TODO: Add your control
notification handler code
here
} |
|
|