首页 > 代码库 > 最简单的MFC
最简单的MFC
#include <SDKDDKVer.h>#include <afxwin.h> #include <afxext.h> #include <iostream>#include <sstream>class MyFrameWnd : public CFrameWnd{public: MyFrameWnd() :CFrameWnd() { Create(0, TEXT("Hello")); m_Menu.CreateMenu(); m_Menu.AppendMenu(MF_STRING, 0, _T("文件")); SetMenu(&m_Menu); }protected: void OnPaint() { CPaintDC dc(this); dc.MoveTo(0, 0); dc.LineTo(200, 200); } void OnLButtonDown(UINT flag, CPoint point) { std::stringstream ss; ss << point.x << "," << point.y << "\n"; ::OutputDebugStringA(ss.str().c_str()); } static const AFX_MSGMAP* PASCAL GetThisMessageMap() { typedef MyFrameWnd ThisClass; typedef CFrameWnd TheBaseClass; static const AFX_MSGMAP_ENTRY _messageEntries[] = { { WM_PAINT, 0, 0, 0, AfxSig_vv, (AFX_PMSG)(AFX_PMSGW)(static_cast< void (AFX_MSG_CALL CWnd::*)(void) > ( &ThisClass :: OnPaint)) }, { WM_LBUTTONDOWN, 0, 0, 0, AfxSig_vwp, (AFX_PMSG)(AFX_PMSGW)(static_cast< void (AFX_MSG_CALL CWnd::*)(UINT, CPoint) > (&ThisClass :: OnLButtonDown)) }, {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } }; static const AFX_MSGMAP messageMap = { &TheBaseClass::GetThisMessageMap, &_messageEntries[0] }; return &messageMap; } virtual const AFX_MSGMAP* GetMessageMap() const { return GetThisMessageMap(); }private: CMenu m_Menu;};class MyApp : public CWinApp{public: MyApp() :CWinApp() { } ~MyApp() { } BOOL InitInstance() { CWinApp::InitInstance(); MyFrameWnd * frame = new MyFrameWnd; m_pMainWnd = frame; m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return true; }};MyApp theApp;
最简单的MFC
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。