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)
}

這樣就實現了鼠標移動到最上面菜單欄就顯示,移下來就隱藏了.

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