最简单的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;

 

转载于:https://www.cnblogs.com/nmgxbc/p/5873887.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值