首先獲取程序窗口大小
在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)
}
這樣就實現了鼠標移動到最上面菜單欄就顯示,移下來就隱藏了.