An Easier Way to Right-Justify MenuTitles

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
joebones
New User
New User
Posts: 7
Joined: Sun May 30, 2010 11:02 am

An Easier Way to Right-Justify MenuTitles

Post by joebones »


An easy way to right-justify MenuTitles would be useful. The right side is the common placement for a "Help" option.

Image

I imagine it being implemented by a simple flag, like this:

Image

Also, Gnozal was even kind enough to demonstrate one method of putting MenuTitles on the right, which I submit below.


-----
Platform: WinXP(SP2)
Proc: Intel, 3Ghz
PB Ver: 4.40

Code: Select all

Enumeration
  #Window_0
EndEnumeration
Enumeration
  #Menu_Window_0
EndEnumeration
Enumeration
  #Menu_Window_0_Item1
  #Menu_Window_0_Item2
  #Menu_Window_0_Item3
EndEnumeration
Procedure MenuTitleRight(hWindow.l, hMenu.l, MenuIndex.l) ; Not working on NT4
  Protected ThisMenuItemInfo.MENUITEMINFO
  ThisMenuItemInfo\cbSize = SizeOf(MENUITEMINFO)
  ThisMenuItemInfo\fMask = #MIIM_FTYPE
  GetMenuItemInfo_(hMenu, MenuIndex, #True, ThisMenuItemInfo)   
  ThisMenuItemInfo\fType = ThisMenuItemInfo\fType | #MFT_RIGHTJUSTIFY
  SetMenuItemInfo_(hMenu, MenuIndex, #True, ThisMenuItemInfo)
  DrawMenuBar_(hWindow)
EndProcedure
If OpenWindow(#Window_0, 450, 200, 400, 419, "MenuTitleRight", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
  If CreateMenu(#Menu_Window_0, WindowID(#Window_0))
    MenuTitle("Title 1") ; 0
    MenuItem(#Menu_Window_0_Item1, "Item 1")
    MenuItem(#Menu_Window_0_Item2, "Item 2")
    MenuTitle("Title 2") ; 1
    MenuItem(#Menu_Window_0_Item3, "Item 3")
    ;
    MenuTitleRight(WindowID(#Window_0), MenuID(#Menu_Window_0), 1)
    ;
    Repeat
      Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_CloseWindow
          Break
      EndSelect
    ForEver
  EndIf
EndIf