Basic framework for the MFC program

xiaoxiao2021-03-06  180

//Min.cpp

// Configure Win32 Application to do the following: // Open the Project Setting dialog from the Project / Setting menu, // Select "Use MFC in Static Library" // or "Use MFC in A Shared DLL" in Microsoft Foundation Class.

#include

class CMinApp: public CWinApp // define application class {public: virtual BOOL InitInstance (); // initialize function application overload}; class CMainWnd: public CFrameWnd {protected: afx_msg void OnLButtonDown (UINT nFlags, CPoint point); afx_msg void OnRbuttondown (uint nflags, cpoint point); declare_message_map ();

BOOL CMinApp :: InitInstance () {CMainWnd * pFrame = new CMainWnd; // creates window objects pFrame-> Create (0, _T ( "Another Minimal MFC Program")); pFrame-> ShowWindow (SW_SHOWMAXIMIZED); pFrame-> UpdateWindow (); this-> m_pmainwnd = pframe; // Take the window as the main window of the program Return True;}

CMINAPP myApp; // Create an application instance

Begin_MESSAGE_MAP (CMAINWND, CFRAMEWND) / / Establishment message mapping ON_WM_LBUTTONDOWN () ON_WM_RBUTTONDOWN () end_MESSAGE_MAP ()

// Process window message, as an example, for simplicity, only processing the left, right-click message void cmainwnd :: ONLBUTTONDOWN (uint nflags, cpoint point) {// Left button cstring szmsg = "You Click LEFT button! / n "; :: MessageBox (getsafehwnd (), szmsg," message ", mb_ok | mb_iconification); cframeWnd :: ONLBUTTONDOWN (NFLAGS, POINT); // Call the default processing function, complete the rest}

void CMainWnd :: OnRButtonDown (UINT nFlags, CPoint point) {// Right CString szMsg = "You click right button / n!"; :: MessageBox (GetSafeHwnd (), szMsg, "Message", MB_OK | MB_ICONINFORMATION); CFrameWnd: : OnRButtondown (NFLAGS, POINT);

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

New Post(0)