HOWTO: Dynamically Change Position of Menu Items on Top-Level Menu BarID: Q230201
|
This article describes how menu item positions on the top-level menu bar can be changed at run time. If the top-level menu items have sub menus they will also be moved with the top-level menu.
Steps to change the position of menu item:
HMENU hMenu;
TCHAR szBuffer[40];
TCHAR buf[50];
MENUITEMINFO MInfo;
int OrigPosition, NewPosition ;
hMenu = GetMenu(hWnd);
MInfo.cbSize = sizeof(MENUITEMINFO);
OrigPosition = 2;
NewPosition = 4;
MInfo.fMask = MIIM_DATA | MIIM_ID |MIIM_SUBMENU |MIIM_TYPE;
MInfo.fType = MFT_STRING;
MInfo.fState = MFS_DEFAULT;
MInfo.dwTypeData = szBuffer;
MInfo.cch = 40; //sizeof(Buffer);
if(GetMenuItemInfo(hMenu, OrigPosition, TRUE, &MInfo))
{
if(InsertMenuItem(hMenu, NewPosition, TRUE, &MInfo)) // Insert between 3 and 4
{
RemoveMenu(hMenu, OrigPosition, MF_BYPOSITION);
DrawMenuBar(hWnd);
}
}
Additional query words:
Keywords : kbMenu kbSDKWin32 kbGrpUser
Version : WINDOWS:95,98
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 21, 1999