WTL怎么让View来响应菜单事件
1个回答
2015-08-08
展开全部
先要改View里面的消息循环,把它写成如下形式:
程序代码
BEGIN_MSG_MAP(CGameView)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_Create, OnCreate)
ALT_MSG_MAP(1) // Handle notify message.
COMMAND_ID_HANDLER(ID_GAME_START_NEW, OnGameStartNew)
END_MSG_MAP()
然后在CMainFrame的消息循环中加入CHAIN_MSG_MAP_ALT_MEMBER():
程序代码
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_Create, OnCreate)
CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
CHAIN_MSG_MAP_ALT_MEMBER(m_view, 1)
END_MSG_MAP()
程序代码
BEGIN_MSG_MAP(CGameView)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_Create, OnCreate)
ALT_MSG_MAP(1) // Handle notify message.
COMMAND_ID_HANDLER(ID_GAME_START_NEW, OnGameStartNew)
END_MSG_MAP()
然后在CMainFrame的消息循环中加入CHAIN_MSG_MAP_ALT_MEMBER():
程序代码
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_Create, OnCreate)
CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
CHAIN_MSG_MAP_ALT_MEMBER(m_view, 1)
END_MSG_MAP()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询