MFC 菜单栏显示隐藏

 首先获取程序窗口大小

在CMainFrame 定义变量CRect clientRect;

在onCreate里获取客户区大小,并隐藏菜单栏

m_wndCommandBar.ShowWindow(SW_HIDE);

GetClientRect(clientRect);

 

BOOL CMainFrame::PreTranslateMessage(pMsg)
{
    if(pMsg->message==WM_MOUSEMOVE)
    {
        if(pMsg->pt.y<15)
        {
            m_wndCommandBar.ShwoWindow(SW_SHOW);
            moveWindow(ClientRect);//没有这句隐藏或显示没用,界面没刷新
        }
        if(pMsg->pt.y>30)
        {
            m_wndCommandBar.ShwoWindow(SW_HIDE);
            moveWindow(ClientRect);
        }
    }
return CFrameWnd::PreTranslateMessage(pMsg)
}

这样就实现了鼠标移动到最上面菜单栏就显示,移下来就隐藏了.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章