First see definition
#define begin_Message_Map (Theclass, Baseclass) /
Const AFX_MSGMap * Theclass :: getMessageMap () const /
{RETURN & THECLASS :: MessageMap;} /
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP THECLASS :: MessageMap = /
{& Baseclass :: MessageMap, & Theclass :: _ Messagentries [0]}; /
AFX_COMDAT const AFX_MSGMAP_ENTRY THECLASS :: _ MessageEntries [] = /
{/
Actual application begin_message_map (myView, cView) equivalent
Const AFX_MSGMap * myview :: getMessageMap () const /
{RETURN & MyView :: MessageMap;} /
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP MyView :: MessageMap = /
{& CView :: MessageMap, & myview :: _ Messagentries [0]}; /
AFX_COMDAT const AFX_MSGMAP_ENTRY MyView :: _ MessageEntries [] = /
{/
Also end_MESSAGE_MAP and Begin_Message_map are pairing
#define end_message_map () /
{0, 0, 0, 0, AFXSIG_END, (AFX_PMSG) 0} /
}; /
The entire program is changed as follows:
#include
#include
#include "resource.h"
Class MyDoc: Public CDocument
{
PUBLIC:
Static const canuntimeclass classmydoc;
Virtual cruntimeclass * getruntimeclass () const;
Static cobject * __stdcall createObject ();
PUBLIC:
CString S;
Cpoint Point;
mydoc ()
{
S = "Welcome to SDI";
POINT.X = 250;
Point.y = 100;
}
}
COBJECT * __STDCALL MYDOC :: CreateObject ()
{Return new mydoc;
Const cruntimeclass mydoc :: classmydoc =
{
"MYDOC", Sizeof (Class MyDoc), 0xffff, Mydoc :: CreateObject,
(CRUNTIMECLASS *) (& cDocument :: classcdocument), null};
Cruntimeclass * mydoc :: getruntimeclass () const
{Return (CRUNTIMECLASS *) (& mydoc :: classmydoc);
Class Myview: Public CVIEW
{
PUBLIC:
Static Const CRUNTIMECLASS CLASSMYVIEW;
Virtual cruntimeclass * getruntimeclass () const;
Static cobject * __stdcall createObject ();
PUBLIC:
Void OnDraw (CDC * D)
{
mydoc * b;
B = (mydoc *) m_pdocument;
D-> SetTextColor (RGB (0, 0, 0));
D-> TextOut (B-> Point.x, B-> Point.y, B-> s);
}
Void Onlbuttondown (uint nflags, cpoint p)
{
mydoc * b;
B = (mydoc *) m_pdocument;
B-> Point.x = p.x;
B-> Point.y = p.y;
Invalidate ();
}
Private:
Static const AFX_MSGMAP_ENTRY _MESSAGEENTRIES [];
protected:
Static AFX_DATA Const AFX_MSGMAP MessageMap;
Virtual const AFX_MSGMAP * getMessageMap () const;
}
COBJECT * __STDCALL MyView :: CreateObject ()
{Return new myview;}
Const cruntimeclass myview :: classmyview =
{
"MyView", sizeof (class myview), 0xffff, myview :: CreateObject,
(CruntimeClass *) (& CView :: Classcview), NULL
}
Cruntimeclass * myview :: getruntimeclass () const
{
Return (CRUNTIMECLASS *) (& myView :: classmyview);
}
Const AFX_MSGMAP * MyView :: getMessageMap () Const
{Return & MyView :: messagemap;
const AFX_MSGMAP MyView :: messagemap =
{& CView :: Messagemap, & myview :: _ Messagentries [0]};
Const AFX_MSGMAP_ENTRY MyView :: _ MessageEntries [] =
{
{
WM_LButtondown, 0, 0, 0, AFXSIG_VWP,
(AFX_PMSG) (Void (CWnd :: *) (UINT, CPOINT) & ONLBUTTONDOWN
}
{0, 0, 0, 0, AFXSIG_END, (AFX_PMSG) 0}
}
Class zzz: Public CWINAPP
{
PUBLIC:
Int InitInstance ()
{
CSINGLEDOCTEMPLATE * Y;
CruntimeClass * W, * D, * V;
D = (cruntimeclass *) (& mydoc :: classmydoc);
W = (CRUNTIMECLASS *) (& CFrameWnd :: ClasscFrameWnd);
v = (cruntimeclass *) (& myview :: classmyview);
y = new csingledoctemplate (IDR_MENU1, D, W, V);
AddDDOCTemplate (Y);
ONFileNew ();
Return 1;
}
}
ZZZ A;
(Full text)