VOID setWindowOnMenuTopMost(HWND hWnd, int iMenu, int iPos) { HMENU hMenu = GetMenu(hWnd); HMENU hSubMenu = GetSubMenu(hMenu, iMenu); UINT uID = GetMenuItemID(hSubMenu, iPos); ASSERT( uID != -1 ); MENUITEMINFO miiTopMost; // ZeroMemory is necessary ZeroMemory(&miiTopMost, sizeof miiTopMost); // fMask: Members to retrieve or set.if you want to modify fState member, just evaluate fMark member with MIIMSTATE // The same to other members, fMask can be one or more values. miiTopMost.fMask = MIIM_STATE; // Fill cbSize member is necessary miiTopMost.cbSize = sizeof MENUITEMINFO; // Fill MENUITEMINFO menu item information;TRUE: menu item posation, FALSE: menu item ID. BOOL bRes = GetMenuItemInfo(hSubMenu, uID, FALSE, &miiTopMost); ASSERT( bRes ); if( miiTopMost.fState == MFS_CHECKED ) { // Set window no topmost, update menu information and redraw menu SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); miiTopMost.fState = MFS_UNCHECKED; SetMenuItemInfo(hSubMenu, uID, FALSE, &miiTopMost); DrawMenuBar(hWnd); } else { // Set window topmost, update menu information and redraw menu SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); miiTopMost.fState = MFS_CHECKED; SetMenuItemInfo(hSubMenu, uID, FALSE, &miiTopMost); DrawMenuBar(hWnd); } return ; } 该函数实现功能:就是一般程序通过菜单选项选择总显示在最前端功能。