class CSomeView:public CView
{
protected:
afx_msg void OnCommandRange(UINT nID);
afx_msg void OnUpdateCommandUIRange(CCmdUI* pCmdUI);
int m_iShape //记录选择了哪个选项
DECLARE_MESSAGE_MAP();
}
BEGIN_MESSAGE_MAP(CSomeView,CView)
ON_COMMAND_RANGE( idFirst, idLast,OnCOmmandRange);
ON_UPDATE_COMMAND_UI_RANGE(idFirst,idLast,OnUpdateCommandUIRange)
END_MESSAGE_MAP()
宏的参数没有类型,是用#define 定义的量
void CMsdrawView::OnDrawShape(UINT nID)
{
m_iShape=nID-ID_DRAW_STROKE+1;
}
void CMsdrawView::OnUpdateDrawShape(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck (m_iShape+ID_DRAW_STROKE-1==pCmdUI->m_nID ?1:0);
}