複製鏈接
請複製以下鏈接發送給好友

DrawMenuBar

鎖定
DrawMenuBar是一個計算機函數,功能是該函數重畫指定菜單的菜單條。
外文名
DrawMenuBar
適用領域
計算機,編程,API
應用學科
數學
函數原型
BOOL DrawMenuBar(HWND hWnd)
如果系統創建窗口以後菜單條被修改,則必須調用此函數來畫修改了的菜單條。
函數原型:BOOL DrawMenuBar(HWND hWnd);
參數:
hWnd:其菜單條需要被重畫的窗口的句柄。
返回值:如果函數調用成功,返回非零值:如果函數調用失敗,返回值是零。若想獲得更多的錯誤信息,請調用GetLastError函數。
速查:Windows NT:及以上版本;Windows:95及以上版本;Windows:2.0及以上版本;頭文件:winuser.h;輸入庫:user32.lib。
示例:
void CMainFrame::OnCwndDeletefilemenu()
{
// This example deletes the leftmost popup menu or leftmost
// popup menu item from the application's main window.
CWnd* pMain = AfxGetMainWnd();
// The main window _can_ be NULL, so this code
// doesn't ASSERT and actually tests.
if (pMain != NULL)
{
// Get the main window's menu
CMenu* pMenu = pMain->GetMenu();
// If there is a menu and it has items, we'll
// delete the first one.
if (pMenu != NULL && pMenu->GetMenuItemCount() > 0)
{
pMenu->DeleteMenu(0, MF_BYPOSITION);
// force a redraw of the menu bar
pMain->DrawMenuBar();
}
// No need to delete pMenu because it is an MFC
// temporary object.
}
}