Microsoft KB Archive/253308: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "&" to "&")
m (Text replacement - """ to """)
 
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, &quot;color&quot;, and one item in the drop-down menu, &quot;red&quot;) 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):
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, &quot;red&quot;);
         lstrcpy(szMenuText, "red");
mni2.dwTypeData = szMenuText;
mni2.dwTypeData = szMenuText;
mni2.cbSize = sizeof(MENUITEMINFO);
mni2.cbSize = sizeof(MENUITEMINFO);
Line 71: Line 71:
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, &quot;color&quot;);
lstrcpy(szMenuText, "color");
mni.dwTypeData = szMenuText;
mni.dwTypeData = szMenuText;
mni.cbSize = sizeof(MENUITEMINFO);
mni.cbSize = sizeof(MENUITEMINFO);
Line 94: Line 94:
PopupMenu MENUEX DISCARDABLE  
PopupMenu MENUEX DISCARDABLE  
BEGIN
BEGIN
     POPUP &quot;MOO-Dummy Popup&quot;,                65535,
     POPUP "MOO-Dummy Popup",                65535,
     MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
     MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
     BEGIN
     BEGIN
         POPUP &quot;Fonts&quot;,                          65535,
         POPUP "Fonts",                          65535,
         MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         BEGIN
         BEGIN
             MENUITEM &quot;Courier&quot;,                    IDM_FONT,
             MENUITEM "Courier",                    IDM_FONT,
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MENUITEM &quot;Times Roman&quot;,                IDM_FONT,
             MENUITEM "Times Roman",                IDM_FONT,
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MENUITEM &quot;Swiss&quot;,                      IDM_FONT,
             MENUITEM "Swiss",                      IDM_FONT,
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MENUITEM &quot;Helvetica&quot;,                  IDM_FONT,
             MENUITEM "Helvetica",                  IDM_FONT,
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MENUITEM &quot;Old English&quot;,                IDM_FONT,
             MENUITEM "Old English",                IDM_FONT,
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
             MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         END
         END
         POPUP &quot;Sizes&quot;,                          65535,
         POPUP "Sizes",                          65535,
         MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         BEGIN
         BEGIN
             MENUITEM &quot;7&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "7",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;8&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "8",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;9&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "9",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;10&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "10",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;11&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "11",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;12&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "12",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;14&quot;,                          IDM_SIZE,MFT_STRING,
             MENUITEM "14",                          IDM_SIZE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
         END
         END
         POPUP &quot;Styles&quot;,                        65535,
         POPUP "Styles",                        65535,
         MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         MFT_STRING | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY,MFS_ENABLED
         BEGIN
         BEGIN
             MENUITEM &quot;Bold&quot;,                        IDM_STYLE,MFT_STRING,
             MENUITEM "Bold",                        IDM_STYLE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;Italic&quot;,                      IDM_STYLE,MFT_STRING,
             MENUITEM "Italic",                      IDM_STYLE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;Strike Out&quot;,                  IDM_STYLE,MFT_STRING,
             MENUITEM "Strike Out",                  IDM_STYLE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;Superscript&quot;,                IDM_STYLE,MFT_STRING,
             MENUITEM "Superscript",                IDM_STYLE,MFT_STRING,
             MFS_ENABLED
             MFS_ENABLED
             MENUITEM &quot;Subscript&quot;,                  IDM_STYLE,MFT_STRING,
             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, &quot;PopupMenu&quot;);
     hMenu = LoadMenu (hInst, "PopupMenu");
     if (!hMenu)
     if (!hMenu)
         return;
         return;
Line 167: Line 167:
     ClientToScreen (hwnd, (LPPOINT)&point);
     ClientToScreen (hwnd, (LPPOINT)&point);


     /* Draw and track the &quot;floating&quot; pop-up menu. */  
     /* 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

Knowledge Base


BUG: MFT_RIGHTORDER Doesn't Work as Expected for Nonresource Menus

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