Handwritten MFC in-depth

zhaozj2021-02-16  64

Preface MFC #define and typedef make C more unrecognizable, the following program is a single document program, which is created a single document form, when the left mouse button, click the form, then in this document form Click on the string "Welcome to SDI".

#include

#include

#include "resource.h"

Class MyDoc: Public CDocument

{

Declare_dyncreate (mydoc) // Unconscence cloud, C does not have this stuff, the first story introduction

PUBLIC:

CString S;

Cpoint Point;

mydoc ()

{

S = "Welcome to SDI";

POINT.X = 250;

Point.y = 100;

}

}

Implement_dyncreate (MyDoc, cdocument) // Do not know the cloud, C does not have this stuff, the second lecture is introduced

Class Myview: Public CVIEW

{

Declare_Dyncreate (MyView)

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 ();

}

Declare_message_map ()

}

Implement_dyncreate (MyView, CView)

Begin_Message_map (MyView, CView) // Do not know the cloud, C does not have this stuff, the third lecture introduction

ON_WM_LBUTTONDOWN () // Do not know the cloud, C does not have this stuff, the third lecture introduction

END_MESSAGE_MAP () // Do not know the cloud, C does not have this stuff, the third lecture

Class zzz: Public CWINAPP

{

PUBLIC:

Int InitInstance ()

{

CSINGLEDOCTEMPLATE * Y;

CruntimeClass * W, * D, * V;

D = runtime_class (mydoc);

w = runtime_class (cframewnd);

v = runtime_class (myView);

y = new csingledoctemplate (IDR_MENU1, D, W, V);

AddDDOCTemplate (Y);

ONFileNew ();

Return 1;

}

}

ZZZ A;

转载请注明原文地址:https://www.9cbs.com/read-17054.html

New Post(0)