1, in
Cyourapp :: InitInstance Registration window class
WNDCLASS wc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wc.hCursor = LoadCursor (IDC_ARROW); wc.hIcon = NULL; wc.hInstance = AfxGetInstanceHandle (); Wc.lpfnWndProc = :: DefWindowProc; // Note that the specified window process wc.lpszclassname = _t ("myWnd_class"); // Specify window wc.lpszMenunaMe = null; wc.style = 0; AFXREGISTERCLASS (& WC);
2, write. The definition of the file class
#ifndef my_wnd # define my_wnd
Class CMYWND: PUBLIC CWND {public: // Configuration function, destructor, etc. Declaration Protected: // Declaration of each message processing function declare_message_map ()};
#ENDIF
3, write .CPP file class implementation
#include "stdafx.h" #include "mywnd.h"
// Implementation of functions such as constructor, secting function
Begin_MESSAGE_MAP (CMYWND, CWND) // Each message shunt end_MESSAGE_MAP ()
// implementation of each message shunt
4. Call the appropriate place in the main program code
CREATE or
Createex creates a window.