什么是GetMenu

核心提示函数原型:HMENU GetMenu(HWND hWnd);参数:hWnd:窗口句柄。(想要获得哪个菜单的句柄,就填写该菜单所在窗口的句柄)返回值:返回值是菜单的句柄。如果给定的窗口没有菜单,则返回NULL。如果窗口是一个子窗口,返回值无定

最佳答案:

函数原型:HMENU GetMenu(HWND hWnd);

详情介绍

函数原型: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)

GetMenu定义

函数原型:HMENU GetMenu(HWND hWnd);

参数:

hWnd:窗口句柄。(想要获得哪个菜单的句柄,就填写该菜单所在窗口的句柄)

返回值:返回值是菜单的句柄。如果给定的窗口没有菜单,则返回NULL。如果窗口是一个子窗口,返回值无定义。

速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:不支持;头文件:winuser.h;输入库:user32.lib。

GetMenu示例

示例: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.    }}

 
友情链接
鄂ICP备19019357号-22