title: vs2019  Installation configuration MFC
 time: 2019 year 8 month 27 day 22:55:57
 <>vs2019 MFC
 <> install MFC
 * 
 open vs erection sequence 
 * 
 Select c++ Desktop development 
 * 
 choice Visual Studio Extended development 
 * 
( For quick configuration ) choice C++ MFC  Generation tools (x86  and  x64) Install 
 * 
 Select Modify , Waiting for installation 
 * 
 Create a new project , choice MFC application 
 <> Empty project   to configure MFC  Fast build 
 *  New header file  #include<afxwin.h>//mfc Header file  // Application class CWinApp, definition MyAPP class , As a derived class ( Subclass ) class 
MyApp : public CWinApp { public: // Virtual function of base class ( Interface ), Subclass to implement  //MFC The entry address of the program  virtual BOOL 
InitInstance(); };// The end of the class should be defined ; class MyFrame:public CFrameWnd { public: MyFrame();
// Constructors  }; 
 * 
 New source file 
#include "mfc.h" MyApp myapp; // Represents the constructor that calls the header file  MyFrame::MyFrame() { // Create entry  Create
(NULL, TEXT(" My first one MFC window ")); } // Implement parent class method  BOOL MyApp::InitInstance() { //1, Creating frame class objects  
MyFrame* myframe = new MyFrame; // Call the method defined above  //2, Display window  myframe->ShowWindow(
SW_SHOWNORMAL); //3, update windows  myframe->UpdateWindow(); //4, Save frame class object pointer  m_pMainWnd = 
myframe; return TRUE;// Initialization is normal , return true } 
 * 
 project ---- attribute ---- Configuration properties ---- senior ----MFC The use of is set to be shared DLL Used in MFC
 * 
 function 
 * 
 Unresolved external symbol  _main, The symbol is in the function  "int __cdecl invoke_main(void)" report errors 
 *  project ---- attribute ---- Configuration properties ---- Linker ---- system ---- Set subsystem as window Windows 
 <> Message mapping 
 * 
 Declare macro , write to .h in 
// Declare message mapping macro , Must be in a class declaration ( Equivalent to an open entrance ) DECLARE_MESSAGE_MAP(); 
 * 
 Boundary macro 
BEGIN_MESSAGE_MAP(MyFrame, CFrameWnd)// start  END_MESSAGE_MAP()// end  
 * 
 Find message macro , Put it in the middle of the boundary macro 
// Boundary macro  // Define message macro , Must be in class implementation  BEGIN_MESSAGE_MAP(MyFrame, CFrameWnd)// start  
ON_WM_LBUTTONDOWN()// Press the left mouse button  ON_WM_CHAR()// keyboard  ON_WM_PAINT()// mapping  END_MESSAGE_MAP()
// end  
 * 
 Find function prototype , The statement reads .h in 
// Declaration of function  // mouse  afx_msg void OnLButtonDown(UINT nFlags, CPoint point); // keyboard  
afx_msgvoid OnChar(UINT, UINT, UINT); // mapping  afx_msg void OnPaint(); 
 * 
 The realization of function , write to .cpp in 
void MyFrame::OnLButtonDown(UINT nFlags, CPoint point) { // The way to the bottom  /*TCHAR 
b[1024]; wsprintf(b, TEXT("x = %d,y = %d"), point.x, point.y); MessageBox(b);*/ 
//mfc String in ,CString CString str; str.Format(TEXT("x coordinate :%d,y coordinate :%d"), point.x, point
.y); MessageBox(str); } void MyFrame::OnChar(UINT key, UINT, UINT) { CString str
; str.Format(TEXT(" It's pressed %c  key "), key); MessageBox(str); } void MyFrame::OnPaint() {
 CPaintDCdc(this); char str[1024] = TEXT("Inifited");// out-of-service String dc.TextOutA(100
, 100, str); dc.TextOutA(100, 200, TEXT("harder")); dc.Ellipse(100, 100, 200, 
200); } 
 * 
 Header file 
#include<afxwin.h>//mfc Header file  // Application class CWinApp, definition MyAPP class , As a derived class ( Subclass ) class MyApp : 
public CWinApp { public: // Virtual function of base class ( Interface ), Subclass to implement  //MFC The entry address of the program  virtual BOOL 
InitInstance(); };// To define a class, add ; class MyFrame:public CFrameWnd { public: MyFrame();
// Constructors  // Declare message mapping macro , Must be in a class declaration ( Equivalent to an open entrance ) DECLARE_MESSAGE_MAP(); // Declaration of function  // mouse  afx_msg 
void OnLButtonDown(UINT nFlags, CPoint point); // keyboard  afx_msg void OnChar(UINT, 
UINT, UINT); // mapping  afx_msg void OnPaint(); }; 
 * 
 source file 
#include "mfc.h"// Import header file  MyApp myapp; // Represents the constructor that calls the header file  MyFrame::MyFrame() { // Create entry 
Create(NULL, TEXT(" My first one MFC window ")); } // Boundary macro  // Define message macro , Must be in class implementation  BEGIN_MESSAGE_MAP(
MyFrame, CFrameWnd)// start  ON_WM_LBUTTONDOWN()// Press the left mouse button  ON_WM_CHAR()// keyboard  ON_WM_PAINT
()// mapping  END_MESSAGE_MAP()// end  void MyFrame::OnLButtonDown(UINT nFlags, CPoint 
point) { // The way to the bottom  /*TCHAR b[1024]; wsprintf(b, TEXT("x = %d,y = %d"), point.x, 
point.y); MessageBox(b);*/ //mfc String in ,CString CString str; str.Format(TEXT(
"x coordinate :%d,y coordinate :%d"), point.x, point.y); MessageBox(str); } void MyFrame::OnChar(
UINT key, UINT, UINT) { CString str; str.Format(TEXT(" It's pressed %c  key "), key); 
MessageBox(str); } void MyFrame::OnPaint() { CPaintDC dc(this); char str[1024] =
TEXT("Inifited"); dc.TextOutA(100, 100, str); dc.TextOutA(100, 200, TEXT(
"harder")); dc.Ellipse(100, 100, 200, 200); } // Implement parent class method  BOOL MyApp::InitInstance(
) { //1, Creating frame class objects  MyFrame* myframe = new MyFrame; // Call the method defined above  //2, Display window  myframe->
ShowWindow(SW_SHOWNORMAL); //3, update windows  myframe->UpdateWindow(); //4, Save frame class object pointer  
m_pMainWnd= myframe; return TRUE;// Initialization is normal , return true } 
 * 
Windows character set 
 * 
c++ In string operation 
#include<string> #include <iostream> using namespace std; int main() { 
// use string  insert #include <string> string s = "hello"; cout << s << endl; const char
* c = s.c_str();//string  Type to char type , Add it in front of it const cout << c << endl;// output c What the pointer points to  
cout<< *c << endl;// output c The first character the pointer points to  cout << *(c + 1) << endl;// output c The second character the pointer points to  cout 
<< *c + 1 << endl;// output c The next character of the first character the pointer points to ASCII The serial number of the code  cout << char(*c + 1) << endl;
// hold ascii Code to character  // appear  "const char *"  Value of type cannot be used for initialization  "char *"  Entity of type  
// Right click item -> attribute ->C/C++-> language -> Conformity mode : Choose no  // Count the length of multibytes  char* ch = "helloWorld"; int num = 
strlen(ch); cout << num << endl; // Counts the string length of wide bytes  wchar_t* wc = L"start"; int num2 
= wcslen(wc); cout << num2 << endl; return 0; } 
 * 
 Multi byte string to wide byte L
// The default is Unicode, Wide byte , and “aaa” It's multibyte , To be able to output , You need to aaa Add one before L, Convert to wide byte  MessageBox(L"baa"); 
 * 
 Declare wide byte string  wchar_t
wchar_t* wc = L"start"; 
 * 
 Statistics wide byte string  wcslen
int num2 = wcslen(wc); 
 * 
Text Adaptive transcoding is done 
// Plus Text then is , Conversion of adaptive coding  MessageBox(TEXT("aaa")); 
//TChar() It's also adaptive coding conversion . So in mfc Recommended in TChar() instead of Char 
 * 
char* And CString The transformation of 
//char*  And CString Conversion between  //1,char* turn CString char* p = "right"; CString cs = CString
(p);// Call the parameterized constructor . //2,CString turn char* CStringA csa = cs; char* ps = csa.GetBuffer();
// If you want to string And CString transformation , You need to put it first string Convert to char*  Let's go again char* And CString transformation  
 * 
 utilize vs Wizard creation mfc
 *  technological process  
 *  Single document 
 * MFC standard
 *  complete  
 *  view  
 *  Class view  
 *  Add mouse , keyboard , mapping  
 *  The frame window is the parent of the view window , The view window is over the frame window , So add a message to the view window 
 *  Right click CMFCView Properties of , Click on the message , Choose what you need add That's it  
Technology