MFC怎么设置RibbonCheckBox状态?它也没个setcheck之类的函数。。。
答案:3 悬赏:20 手机版
解决时间 2021-11-09 01:02
- 提问者网友:浩歌待明月
- 2021-11-08 17:36
MFC怎么设置RibbonCheckBox状态?它也没个setcheck之类的函数。。。
最佳答案
- 五星知识达人网友:等灯
- 2021-11-08 17:54
生成一个带Ribbon的工程,MainFrm.cpp里面有现成的代码,照着写就可以了:
ON_COMMAND(ID_VIEW_CAPTION_BAR, &CMainFrame::OnViewCaptionBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR,
&CMainFrame::OnUpdateViewCaptionBar)
============================================================
CMFCRibbonButton* pBtnCaptionBar = new CMFCRibbonCheckBox(ID_VIEW_CAPTION_BAR, strTemp);
pPanelView->Add(pBtnCaptionBar);
============================================================
void CMainFrame::OnViewCaptionBar()
{
m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW);
RecalcLayout(FALSE);
}
void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_wndCaptionBar.IsVisible());
}
ON_COMMAND(ID_VIEW_CAPTION_BAR, &CMainFrame::OnViewCaptionBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR,
&CMainFrame::OnUpdateViewCaptionBar)
============================================================
CMFCRibbonButton* pBtnCaptionBar = new CMFCRibbonCheckBox(ID_VIEW_CAPTION_BAR, strTemp);
pPanelView->Add(pBtnCaptionBar);
============================================================
void CMainFrame::OnViewCaptionBar()
{
m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW);
RecalcLayout(FALSE);
}
void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_wndCaptionBar.IsVisible());
}
全部回答
- 1楼网友:山河有幸埋战骨
- 2021-11-08 19:39
((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);
- 2楼网友:神也偏爱
- 2021-11-08 18:17
单选框,是一种按钮,直接双击它,在它里面写代码就行了
就像是写按钮的事件一样
就像是写按钮的事件一样
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯