Microsoft KB Archive/253308: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
(One intermediate revision by the same user not shown) | |||
Line 53: | Line 53: | ||
The MFT_RIGHTORDER style doesn't work as expected (to cause the submenu to cascade from right to left) when the menu is dynamically created; that is, when the menu is not loaded from the resource.<br /> | The MFT_RIGHTORDER style doesn't work as expected (to cause the submenu to cascade from right to left) when the menu is dynamically created; that is, when the menu is not loaded from the resource.<br /> | ||
<br /> | <br /> | ||
For example, a pop-up menu (for example, a menu that contains one submenu, | For example, a pop-up menu (for example, a menu that contains one submenu, "color", and one item in the drop-down menu, "red") is created dynamically, by using the MFT_RIGHTORDER style, in order for the submenu to drop down from right to left. Currently, because the menu is not loaded from the resource, the submenu still drops down from left to right, even though the MFT_RIGHTORDER style is used. See the following code (this code does not work correctly with MFT_RIGHTORDER): | ||
<pre class="codesample">HMENU hmenu,submenu; | <pre class="codesample">HMENU hmenu,submenu; | ||
MENUITEMINFO mni, mni2; | MENUITEMINFO mni, mni2; | ||
Line 62: | Line 62: | ||
mni2.fMask= MIIM_DATA|MIIM_TYPE; | mni2.fMask= MIIM_DATA|MIIM_TYPE; | ||
mni2.fType = MFT_RIGHTJUSTIFY | MFT_RIGHTORDER | MFT_STRING; | mni2.fType = MFT_RIGHTJUSTIFY | MFT_RIGHTORDER | MFT_STRING; | ||
lstrcpy(szMenuText, | lstrcpy(szMenuText, "red"); | ||
mni2.dwTypeData = szMenuText; | mni2.dwTypeData = szMenuText; | ||
mni2.cbSize = sizeof(MENUITEMINFO); | mni2.cbSize = sizeof(MENUITEMINFO); | ||
mni2.cch = sizeof(szMenuText); | mni2.cch = sizeof(szMenuText); | ||
InsertMenuItem(submenu, 0, TRUE, & | InsertMenuItem(submenu, 0, TRUE, &mni2); | ||
hmenu = CreatePopupMenu(); | hmenu = CreatePopupMenu(); | ||
mni.fMask= MIIM_DATA|MIIM_TYPE|MIIM_SUBMENU; | mni.fMask= MIIM_DATA|MIIM_TYPE|MIIM_SUBMENU; | ||
mni.fType = MFT_RIGHTJUSTIFY | MFT_RIGHTORDER | MFT_STRING; | mni.fType = MFT_RIGHTJUSTIFY | MFT_RIGHTORDER | MFT_STRING; | ||
lstrcpy(szMenuText, | lstrcpy(szMenuText, "color"); | ||
mni.dwTypeData = szMenuText; | mni.dwTypeData = szMenuText; | ||
mni.cbSize = sizeof(MENUITEMINFO); | mni.cbSize = sizeof(MENUITEMINFO); | ||
mni.cch = sizeof(szMenuText); | mni.cch = sizeof(szMenuText); | ||
mni.hSubMenu = submenu; | mni.hSubMenu = submenu; | ||
InsertMenuItem(hmenu,0,TRUE,& | InsertMenuItem(hmenu,0,TRUE,&mni); | ||
pt.x = (long) LOWORD(lParam); | pt.x = (long) LOWORD(lParam); | ||
pt.y = (long) HIWORD(lParam); | pt.y = (long) HIWORD(lParam); | ||
ClientToScreen(hWnd,& | ClientToScreen(hWnd,&pt); | ||
TrackPopupMenu(hmenu, TPM_RIGHTALIGN,pt.x,pt.y, 0, hWnd,NULL); | TrackPopupMenu(hmenu, TPM_RIGHTALIGN,pt.x,pt.y, 0, hWnd,NULL); | ||
Line 94: | Line 94: | ||
PopupMenu MENUEX DISCARDABLE | PopupMenu MENUEX DISCARDABLE | ||
BEGIN | BEGIN | ||
POPUP | POPUP "MOO-Dummy Popup", 65535, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
BEGIN | BEGIN | ||
POPUP | POPUP "Fonts", 65535, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
BEGIN | BEGIN | ||
MENUITEM | MENUITEM "Courier", IDM_FONT, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
MENUITEM | MENUITEM "Times Roman", IDM_FONT, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
MENUITEM | MENUITEM "Swiss", IDM_FONT, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
MENUITEM | MENUITEM "Helvetica", IDM_FONT, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
MENUITEM | MENUITEM "Old English", IDM_FONT, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
END | END | ||
POPUP | POPUP "Sizes", 65535, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
BEGIN | BEGIN | ||
MENUITEM | MENUITEM "7", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "8", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "9", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "10", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "11", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "12", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "14", IDM_SIZE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
END | END | ||
POPUP | POPUP "Styles", 65535, | ||
MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED | ||
BEGIN | BEGIN | ||
MENUITEM | MENUITEM "Bold", IDM_STYLE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "Italic", IDM_STYLE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "Strike Out", IDM_STYLE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "Superscript", IDM_STYLE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
MENUITEM | MENUITEM "Subscript", IDM_STYLE,MFT_STRING, | ||
MFS_ENABLED | MFS_ENABLED | ||
END | END | ||
Line 151: | Line 151: | ||
/* Get the menu for the popup from the resource file. */ | /* Get the menu for the popup from the resource file. */ | ||
hMenu = LoadMenu (hInst, | hMenu = LoadMenu (hInst, "PopupMenu"); | ||
if (!hMenu) | if (!hMenu) | ||
return; | return; | ||
Line 165: | Line 165: | ||
* TrackPopup expects. | * TrackPopup expects. | ||
*/ | */ | ||
ClientToScreen (hwnd, (LPPOINT)& | ClientToScreen (hwnd, (LPPOINT)&point); | ||
/* Draw and track the | /* Draw and track the "floating" pop-up menu. */ | ||
TrackPopupMenu (hMenuTrackPopup, 0, point.x, point.y, 0, hwnd, NULL); | TrackPopupMenu (hMenuTrackPopup, 0, point.x, point.y, 0, hwnd, NULL); | ||
Latest revision as of 13:52, 21 July 2020
Article ID: 253308
Article Last Modified on 11/1/2006
APPLIES TO
- Microsoft Platform Software Development Kit-January 2000 Edition, when used with:
- Microsoft Windows 98 Standard Edition
- Microsoft Windows NT 4.0
This article was previously published under Q253308
SYMPTOMS
The MFT_RIGHTORDER style doesn't work as expected (to cause the submenu to cascade from right to left) when the menu is dynamically created; that is, when the menu is not loaded from the resource.
For example, a pop-up menu (for example, a menu that contains one submenu, "color", and one item in the drop-down menu, "red") is created dynamically, by using the MFT_RIGHTORDER style, in order for the submenu to drop down from right to left. Currently, because the menu is not loaded from the resource, the submenu still drops down from left to right, even though the MFT_RIGHTORDER style is used. See the following code (this code does not work correctly with MFT_RIGHTORDER):
HMENU hmenu,submenu; MENUITEMINFO mni, mni2; char szMenuText[30]; POINT pt; submenu = CreateMenu(); mni2.fMask= MIIM_DATA|MIIM_TYPE; mni2.fType = MFT_RIGHTJUSTIFY | MFT_RIGHTORDER | MFT_STRING; lstrcpy(szMenuText, "red"); mni2.dwTypeData = szMenuText; mni2.cbSize = sizeof(MENUITEMINFO); mni2.cch = sizeof(szMenuText); InsertMenuItem(submenu, 0, TRUE, &mni2); hmenu = CreatePopupMenu(); mni.fMask= MIIM_DATA|MIIM_TYPE|MIIM_SUBMENU; mni.fType = MFT_RIGHTJUSTIFY | MFT_RIGHTORDER | MFT_STRING; lstrcpy(szMenuText, "color"); mni.dwTypeData = szMenuText; mni.cbSize = sizeof(MENUITEMINFO); mni.cch = sizeof(szMenuText); mni.hSubMenu = submenu; InsertMenuItem(hmenu,0,TRUE,&mni); pt.x = (long) LOWORD(lParam); pt.y = (long) HIWORD(lParam); ClientToScreen(hWnd,&pt); TrackPopupMenu(hmenu, TPM_RIGHTALIGN,pt.x,pt.y, 0, hWnd,NULL);
RESOLUTION
To use a right-to-left drop-down submenu, you must put the menu in the resource, and then load the menu at run time, as follows:
// The menu in the resource file resembles the following: PopupMenu MENUEX DISCARDABLE BEGIN POPUP "MOO-Dummy Popup", 65535, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED BEGIN POPUP "Fonts", 65535, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED BEGIN MENUITEM "Courier", IDM_FONT, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED MENUITEM "Times Roman", IDM_FONT, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED MENUITEM "Swiss", IDM_FONT, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED MENUITEM "Helvetica", IDM_FONT, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED MENUITEM "Old English", IDM_FONT, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED END POPUP "Sizes", 65535, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED BEGIN MENUITEM "7", IDM_SIZE,MFT_STRING, MFS_ENABLED MENUITEM "8", IDM_SIZE,MFT_STRING, MFS_ENABLED MENUITEM "9", IDM_SIZE,MFT_STRING, MFS_ENABLED MENUITEM "10", IDM_SIZE,MFT_STRING, MFS_ENABLED MENUITEM "11", IDM_SIZE,MFT_STRING, MFS_ENABLED MENUITEM "12", IDM_SIZE,MFT_STRING, MFS_ENABLED MENUITEM "14", IDM_SIZE,MFT_STRING, MFS_ENABLED END POPUP "Styles", 65535, MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED BEGIN MENUITEM "Bold", IDM_STYLE,MFT_STRING, MFS_ENABLED MENUITEM "Italic", IDM_STYLE,MFT_STRING, MFS_ENABLED MENUITEM "Strike Out", IDM_STYLE,MFT_STRING, MFS_ENABLED MENUITEM "Superscript", IDM_STYLE,MFT_STRING, MFS_ENABLED MENUITEM "Subscript", IDM_STYLE,MFT_STRING, MFS_ENABLED END END END
The code to load that right-to-left pop-up menu would resemble the following:
HMENU hMenu; HMENU hMenuTrackPopup; /* Get the menu for the popup from the resource file. */ hMenu = LoadMenu (hInst, "PopupMenu"); if (!hMenu) return; /* Get the first menu in it, which we will use for the call to * TrackPopup(). This could also have been created on the fly using * CreatePopupMenu and then we could have used InsertMenu() or * AppendMenu. */ hMenuTrackPopup = GetSubMenu (hMenu, 0); /* Convert the mouse point to screen coordinates because that is what * TrackPopup expects. */ ClientToScreen (hwnd, (LPPOINT)&point); /* Draw and track the "floating" pop-up menu. */ TrackPopupMenu (hMenuTrackPopup, 0, point.x, point.y, 0, hwnd, NULL); /* Destroy the menu because we are done with it. */ DestroyMenu (hMenu);
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Keywords: kbbidi kbbug kblocalization kboswin2000fix kboswin98fix kbpending KB253308