最简单的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;
上一篇:JavaScript中对象的比较


下一篇:【CodeForces】827 D. Best Edge Weight 最小生成树+倍增LCA+并查集