函式原型:HMENU GetMenu(HWND hWnd);
參數:
hWnd:視窗句柄。(想要獲得哪個選單的句柄,就填寫該選單所在視窗的句柄)
返回值:返回值是選單的句柄。如果給定的視窗沒有選單,則返回NULL。如果視窗是一個子視窗,返回值無定義。
速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:不支持;頭檔案:winuser.h;輸入庫:user32.lib。
基本介紹
- 中文名:HMENU GetMenu
- 外文名:GetMenu
- 類型:函式
- 函式功能:取得給指定視窗分配的選單句柄
- 函式原型:HMENU GetMenu(HWND hWnd)
定義
示例
示例: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. }}