1.创建并显示菜单 SHMENUBARINFO mbi; ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); mbi.cbSize=sizeof(SHMENUBARINFO); mbi.hwndParent=m_hWnd; mbi.hInstRes=::AfxGetInstanceHandle(); mbi.dwFlags=SHCMBF_HMENU|SHCMBF_HIDESIPBUTTON;//隐藏SIP mbi.nToolBarId=IDR_MYMENU; SHCreateMenuBar(&mbi); 2.隐藏菜单 HWND hwnd=::SHFindMenuBar(m_hWnd); if(hwnd!=NULL) ::ShowWindow(hwnd,SW_HIDE); 3.隐藏某个子菜单项 TBBUTTONINFO tbbi = {0}; tbbi.cbSize = sizeof(TBBUTTONINFO); tbbi.dwMask = TBIF_LPARAM | TBIF_BYINDEX; ::SendMessageW(mbi.hwndMB, TB_GETBUTTONINFO,0, (LPARAM)&tbbi); //0为SK1,1为SK2(即左右软键) g_hMenu = (HMENU)tbbi.lParam;//g_hMenu为全局变量,这样就可以在任何地方隐藏子菜单了 4.使某个SK(Soft Key)不可用 ::SHEnableSoftkey(mbi.hwndMB,0,TRUE,FALSE); 5.子菜单打勾 HMENU hMenu; HWND hwndMenuBar = ::SHFindMenuBar(m_hWnd); //m_hWnd是窗口句柄 tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_LPARAM|TBIF_BYINDEX; //第三个参数1表示右菜单,为0表示左菜单 ::SendMessage(hwndMenuBar, TB_GETBUTTONINFO, 1, (LPARAM)&tbbi); hMenu = (HMENU)tbbi.lParam; //hMenu这个句柄就是菜单操作常用的句柄了,获得这个句柄非常有用。 DWORD ack = CheckMenuItem(hMenu,ID_STARTUP,MF_BYCOMMAND|MF_CHECKED);