[TC 11.55rc2] Lister menu doesn't support right to left

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

[TC 11.55rc2] Lister menu doesn't support right to left

Post by *white »

The Lister menu doesn't quite support right to left. Main menu items that are right aligned when using lef to right language (%n, 100%), stay right aligned when using right to left language. Try for example Arabic language.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *ghisler(Author) »

Sorry, HELP_BREAK doesn't work with right to left languages. In detail, menu items in right to left languages use flags
MFT_RIGHTJUSTIFY | MFT_RIGHTORDER
and MFT_RIGHTORDER is the same flag as MF_HELP, which is used for the help break.

Moderator message from: ghisler(Author) » 2025-05-21, 09:17 UTC

Moved to will not be changed
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *white »

ghisler(Author) wrote: 2025-05-21, 09:13 UTC Sorry, HELP_BREAK doesn't work with right to left languages. In detail, menu items in right to left languages use flags
MFT_RIGHTJUSTIFY | MFT_RIGHTORDER
and MFT_RIGHTORDER is the same flag as MF_HELP, which is used for the help break.
Can this be solved using the same method as the AHK example program below? The menus don't cascade from right to left, but apart from that, it works.

Code: Select all

#Requires AutoHotkey v1
#SingleInstance Force
#NoEnv

; Windows API constants from winuser.h
MF_STRING := 0x0000
MF_POPUP := 0x0010
MF_HELP := 0x4000
MFT_RIGHTJUSTIFY := 0x4000
MFT_RIGHTORDER := 0x2000
MIIM_TYPE := 0x0010
MIIM_ID := 0x0002
MIIM_SUBMENU := 0x0004

; Global variable to track LTR/RTL mode
global isRTL := 0

; Create GUI
Gui, +LastFound
hWnd := WinExist()

; Initialize menu
BuildMenu()

; Show GUI
Gui, Show, w600 h300, Menu test - Alignment: Left to right

; Menu command handlers
OnMessage(0x111, "WM_COMMAND")

return

WM_COMMAND(wParam, lParam) {
    if (wParam = 1001) { ; Left to Right
        isRTL := 0
        BuildMenu()
        Gui, Show, , Menu test - Alignment: Left to right
    }
    else if (wParam = 1002) { ; Right to Left
        isRTL := 1
        BuildMenu()
        Gui, Show, , Menu test - Alignment: Right to left
    }
    else if (wParam = 2001) { ; About
        MsgBox, 0, Menu test, Test program to test menu alignment.
    }
}

BuildMenu() {
    global hWnd, isRTL, MF_STRING, MF_POPUP, MF_HELP, MFT_RIGHTJUSTIFY, MFT_RIGHTORDER, MIIM_TYPE, MIIM_ID, MIIM_SUBMENU

    ; Destroy existing menu
    if (hMenuBar)
        DllCall("DestroyMenu", "Ptr", hMenuBar)
    if (hAlignmentMenu)
        DllCall("DestroyMenu", "Ptr", hAlignmentMenu)
    if (hEditMenu)
        DllCall("DestroyMenu", "Ptr", hEditMenu)
    if (hViewMenu)
        DllCall("DestroyMenu", "Ptr", hViewMenu)
    if (hHelpMenu)
        DllCall("DestroyMenu", "Ptr", hHelpMenu)

    ; Create new menu bar and submenus
    hMenuBar := DllCall("CreateMenu", "Ptr")
    hAlignmentMenu := DllCall("CreateMenu", "Ptr")
    hEditMenu := DllCall("CreateMenu", "Ptr")
    hViewMenu := DllCall("CreateMenu", "Ptr")
    hHelpMenu := DllCall("CreateMenu", "Ptr")

    ; Add menus to menu bar based on LTR/RTL mode
    if (!isRTL) { ; LTR: Alignment, Edit, View on left, Help on right
        ; Populate Alignment menu, LTR mode
        DllCall("AppendMenu", "Ptr", hAlignmentMenu, "UInt", MF_STRING, "UInt", 1001, "Str", "Left to Right")
        DllCall("AppendMenu", "Ptr", hAlignmentMenu, "UInt", MF_STRING, "UInt", 1002, "Str", "Right to Left")
        ; Populate Edit menu, LTR mode
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1101, "Str", "Cut")
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1102, "Str", "Copy")
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1103, "Str", "Paste")
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1104, "Str", "Select All")
        ; Populate View menu, LTR mode
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1201, "Str", "Full Screen")
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1202, "Str", "Zoom In")
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1203, "Str", "Zoom Out")
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1204, "Str", "Toggle Grid")
        ; Populate Help menu, LTR mode
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2001, "Str", "About")
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2002, "Str", "User Guide")
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2003, "Str", "Check for Updates")
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2004, "Str", "Technical Support")
        ; Add to menu bar
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP, "Ptr", hAlignmentMenu, "Str", "Alignment")
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP, "Ptr", hEditMenu, "Str", "Edit")
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP, "Ptr", hViewMenu, "Str", "View")
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP | MF_HELP, "Ptr", hHelpMenu, "Str", "Help")
    } else { ; RTL: Help on left, View, Edit, Alignment on right
        ; Populate Alignment menu, RTL mode
        DllCall("AppendMenu", "Ptr", hAlignmentMenu, "UInt", MF_STRING | MFT_RIGHTORDER, "UInt", 1001, "Str", "Left to Right")
        DllCall("AppendMenu", "Ptr", hAlignmentMenu, "UInt", MF_STRING, "UInt", 1002, "Str", "Right to Left")
        ; Populate Edit menu, RTL mode
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING | MFT_RIGHTORDER, "UInt", 1101, "Str", "Cut")
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1102, "Str", "Copy")
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1103, "Str", "Paste")
        DllCall("AppendMenu", "Ptr", hEditMenu, "UInt", MF_STRING, "UInt", 1104, "Str", "Select All")
        ; Populate View menu, RTL mode
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING | MFT_RIGHTORDER, "UInt", 1201, "Str", "Full Screen")
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1202, "Str", "Zoom In")
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1203, "Str", "Zoom Out")
        DllCall("AppendMenu", "Ptr", hViewMenu, "UInt", MF_STRING, "UInt", 1204, "Str", "Toggle Grid")
        ; Populate Help menu, RTL mode
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING | MFT_RIGHTORDER, "UInt", 2001, "Str", "About")
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2002, "Str", "User Guide")
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2003, "Str", "Check for Updates")
        DllCall("AppendMenu", "Ptr", hHelpMenu, "UInt", MF_STRING, "UInt", 2004, "Str", "Technical Support")
        ; Add to menu bar
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP, "Ptr", hHelpMenu, "Str", "Help")
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP | MFT_RIGHTJUSTIFY, "Ptr", hViewMenu, "Str", "View")
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP, "Ptr", hEditMenu, "Str", "Edit")
        DllCall("AppendMenu", "Ptr", hMenuBar, "UInt", MF_POPUP, "Ptr", hAlignmentMenu, "Str", "Alignment")
    }

    ; Attach menu bar to GUI
    DllCall("SetMenu", "Ptr", hWnd, "Ptr", hMenuBar)
    DllCall("DrawMenuBar", "Ptr", hWnd)
}

GuiClose:
ExitApp
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *ghisler(Author) »

The menus don't cascade from right to left
Well, that's the problem, users of RTL languages expect that menus cascade from right to left.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *white »

ghisler(Author) wrote: 2025-05-21, 09:13 UTC .. and MFT_RIGHTORDER is the same flag as MF_HELP, which is used for the help break.
I think you meant MFT_RIGHTJUSTIFY.
ghisler(Author) wrote: 2025-05-22, 06:57 UTC
The menus don't cascade from right to left
Well, that's the problem, users of RTL languages expect that menus cascade from right to left.
You brought up these flags, but as far as I know, the flags MFT_RIGHTORDER and MFT_RIGHTJUSTIFY control text alignment and menu item positioning within the menu or menu bar, not the submenu’s popup direction. The native Windows API calls (CreateMenu, AppendMenu, SetMenu) cannot make submenus cascade to the left. I don't know how you solved this, but I think it goes beyond using the API calls. It is possible, if not likely, that this is why you cannot use mixed justification in the menu bar when using right-to-left mode. But I don't think it is caused by these flags.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *ghisler(Author) »

I don't think that the missing menu bar break is such a big problem that I should try to find a solution here, sorry. I could try leaving out the MFT_RIGHTJUSTIFY flag for some of the icons, but I'm sure that this would break something else.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *white »

ghisler(Author) wrote: 2025-05-23, 07:28 UTC I don't think that the missing menu bar break is such a big problem that I should try to find a solution here, sorry. I could try leaving out the MFT_RIGHTJUSTIFY flag for some of the icons, but I'm sure that this would break something else.
To answer my own question, I don't think it is possible. I think as soon as RTL cascading is somehow enabled, MFT_RIGHTJUSTIFY will be the default and there is no such thing as MFT_LEFTJUSTIFY to disable it. Similar to Lazarus' user drawn menus, if you set Bidimode of the main menu to right to left, the menu items in the menu bar are right justified and the only justify option for each individual menu item is to force them to the right ;) I'm still curious though how RTL cascading is technically enabled for the standard menu in TC 32-bit when icons in the menu are disabled.

Perhaps a text like "HELP_BREAK has no effect in right-to-left languages." could be added to the help text:
{Menu file layout:} wrote: - With the command HELP_BREAK you insert a break in the main menu. After that break, all menus will be right adjusted. Note: STARTMENU cannot follow directly after HELP_BREAK!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *ghisler(Author) »

I will add a note to the help.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc2] Lister menu doesn't support right to left

Post by *white »

ghisler(Author) wrote: 2025-05-25, 09:46 UTC I will add a note to the help.
Confirmed that the note is added, thanks.
Post Reply