Page 2 of 2

Re: How use #MFT_MENUBARBREAK for SetMenuItemInfo ?

Posted: Sat Apr 05, 2025 12:47 pm
by breeze4me
@BarryG
hSubmenu = OpenSubMenu("sub")
Windows only trick. :wink:

Code: Select all

UsePNGImageDecoder()

If OpenWindow(0, 600, 250, 200, 100, "Menu Example")
  
  hImg = LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/ToolBar/Open.png")
  
  menu_app = CreateImageMenu(#PB_Any, WindowID(0))
  
  If menu_app
    
    MenuTitle("title1") ; Index 0
    MenuItem(10, "10"   +Chr(9)+"Ctrl+O")
    MenuItem(11, "11"   +Chr(9)+"Ctrl+S")
    MenuItem(12, "12"+Chr(9)+"Ctrl+A")
    MenuItem(13, "13"  +Chr(9)+"Ctrl+C")
    
    MenuTitle("title2") ; Index 1
    MenuItem(14, "item 14")
    hSubmenu = OpenSubMenu("sub")
    For i = 15 To 50
      MenuItem(i, "item " + i, hImg) ; Want a split in the middle of these items.
    Next
    CloseSubMenu()
    
    Define item.MENUITEMINFO
    If hSubMenu
      item\cbSize = SizeOf(MENUITEMINFO)
      item\fMask = #MIIM_FTYPE | #MIIM_ID| #MIIM_DATA
      
      split_point = (50 - 15) / 2 + 1
      If GetMenuItemInfo_(hSubMenu, split_point, #True, item)
        item\fType | #MFT_MENUBARBREAK
        SetMenuItemInfo_(hSubMenu, split_point, #True, item)
      EndIf
    EndIf
    
    MenuTitle("title3") ; Index 2
    MenuItem(51, "51"   +Chr(9)+"Ctrl+O")
    MenuItem(52, "52"   +Chr(9)+"Ctrl+O")
    MenuItem(52, "53"   +Chr(9)+"Ctrl+S")
    
  EndIf
  
  Repeat
    e = WaitWindowEvent()
    If e = #PB_Event_Menu
      Debug EventMenu()
    EndIf
  Until e = #PB_Event_CloseWindow
  
EndIf

Re: How use #MFT_MENUBARBREAK for SetMenuItemInfo ?

Posted: Sat Apr 05, 2025 1:26 pm
by BarryG
YOU FREAKING LEGEND! :D It works great. Thank you so much!

Re: How use #MFT_MENUBARBREAK for SetMenuItemInfo ?

Posted: Sun Jun 08, 2025 3:13 am
by BarryG
Actually, I just noted that while this works on 6.10, on 6.21 it makes the right and bottom sides of all icons be cropped by 1 pixel. :(

Image