【发布时间】:2009-08-30 00:43:51
【问题描述】:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
为什么要定义这些标签?
CSortHeaderCtrl::CSortHeaderCtrl()
: m_iSortColumn( -1 )
, m_bSortAscending( TRUE )
{
}
冒号后面的两个函数是干什么用的?
BEGIN_MESSAGE_MAP(CSortHeaderCtrl, CHeaderCtrl)
//{{AFX_MSG_MAP(CSortHeaderCtrl)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
C#中有类似的东西吗?
这是干什么用的?
virtual ~CSortHeaderCtrl();
为什么要将析构函数设置为虚函数?
void CSortHeaderCtrl::Serialize( CArchive& ar )
什么时候调用这个函数?
这是从父级扩展而来的吗?
顺便说一句,当你想扩展一个 MFC 类时,你会阅读什么文档?
既然我们不知道它有什么功能,我们可以覆盖什么功能?
以下是头文件:
/* File: SortHeaderCtrl.h
Purpose: Provides the header control, with drawing of
the arrows, for the list control.
*/
#ifndef SORTHEADERCTRL_H
#define SORTHEADERCTRL_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CSortHeaderCtrl : public
CHeaderCtrl { // Construction public:
CSortHeaderCtrl();
// Attributes public:
// Operations public:
// Overrides // ClassWizard generated
virtual function overrides
//{{AFX_VIRTUAL(CSortHeaderCtrl)
public: virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation public: virtual
~CSortHeaderCtrl();
void SetSortArrow(
const int iColumn,
const BOOL bAscending );
// Generated message map functions
protected:
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct );
int m_iSortColumn;
BOOL m_bSortAscending;
//{{AFX_MSG(CSortHeaderCtrl) //
NOTE - the ClassWizard will add and
remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP() };
//{{AFX_INSERT_LOCATION}} // Microsoft
Visual C++ will insert additional
declarations immediately before the
previous line.
#endif // SORTHEADERCTRL_H
【问题讨论】:
-
void CSortHeaderCtrl::Serialize(CArchive& ar) 什么时候调用这个函数?这是从父级扩展而来的吗?顺便说一句,当你想扩展一个 MFC 类时,你会阅读什么文档?由于我们不知道它有什么功能,我们可以覆盖什么功能......有人回答最后一个问题吗?谢谢