Remove space for checkmarks in front of menu item?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Lord
Addict
Addict
Posts: 900
Joined: Tue May 26, 2009 2:11 pm

Remove space for checkmarks in front of menu item?

Post by Lord »

Hello!

How can I remove the space for checkmarks in front of menu items?

I tried to adapt an snippet from Fluid Byte but with no success:

Code: Select all

#MNS_NOCHECK = $80000000
#MIM_STYLE = $00000010

Structure MENUINFO
  cbSize.l
  fMask.l
  dwStyle.l
  cyMax.l
  hbrBack.l
  dwContextHelpID.l
  dwMenuData.l
EndStructure

hWindow=OpenWindow(1,0,0,640,480,"",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

hMenu=CreateMenu(1, WindowID(1))
MenuTitle("Datei")
MenuItem(1, "Open")
MenuItem(2, "Save")
MenuItem(3, "Save as")
hSubMenu = OpenSubMenu("Recent files")
MenuItem(5, "File 1")
MenuItem(6, "File 2")
CloseSubMenu()
MenuItem(4, "Quit")



mi.MENUINFO
mi\cbSize = SizeOf(MENUINFO)
mi\fMask = #MIM_STYLE
mi\dwStyle = #MNS_NOCHECK

; SetMenuInfo_(MenuID(1),mi)
; SetMenuInfo_(hMenu,mi);  Doesn't work with whole menu
SetMenuInfo_(MenuID(1),mi)
SetMenuInfo_(hSubMenu,mi); workes only with submenu

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
It works with a sub menu, but not with the whole menu. I didn't really expect
that it would work because the help manual states that CreateMenu() returns
nothing back.
Any ideas how it can be done for a menu (sub menu can have checkmarks)?
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Remove space for checkmarks in front of menu item?

Post by RASHAD »

Hi

Code: Select all

#MNS_NOCHECK = $80000000
#MIM_STYLE = $00000010

Structure MENUINFO
  cbSize.l
  fMask.l
  dwStyle.l
  cyMax.l
  hbrBack.l
  dwContextHelpID.l
  dwMenuData.l
EndStructure


OpenWindow(1,0,0,640,480,"",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

hMenu=CreateMenu(1, WindowID(1))
MenuTitle("Datei")
MenuItem(1, "Open")
MenuItem(2, "Save")
MenuItem(3, "Save as")
hSubMenu = OpenSubMenu("Recent files")
MenuItem(5, "File 1")
MenuItem(6, "File 2")
CloseSubMenu()
MenuItem(4, "Quit")

mi.MENUINFO
mi\cbSize = SizeOf(MENUINFO)
mi\fMask = #MIM_STYLE
mi\dwStyle = #MNS_NOCHECK

hsMenu = GetSubMenu_(hMenu, 0)
SetMenuInfo_(hsMenu,mi)
SetMenuInfo_(hSubMenu,mi); workes only with submenu

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Egypt my love
User avatar
Lord
Addict
Addict
Posts: 900
Joined: Tue May 26, 2009 2:11 pm

Re: Remove space for checkmarks in front of menu item?

Post by Lord »

Hello Rashad!

Thank you for your splendid code (as usual).
That is the way to go.

Greetings to Egypt,

Lord
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Remove space for checkmarks in front of menu item?

Post by RASHAD »

You are welcome
New with the next snippet
1- Support for PB x86 & x64
2- Using new tech. (#MIM_APPLYTOSUBMENUS)
3- Using background image

Hope you like it

Code: Select all

#MNS_NOCHECK = $80000000
#MIM_BACKGROUND = 2
#MIM_STYLE = $00000010
#MIM_APPLYTOSUBMENUS = $80000000 

Structure MENUINFO
   cbSize.l
   fMask.l
   dwStyle.l
   cyMax.l
   hbrBack.l
   dwContextHelpID.l
   dwMenuData.l
   CompilerIf #PB_Compiler_Processor  = #PB_Processor_x64
    PB_Alignment2.b[12]
   CompilerEndIf
EndStructure

CreateImage(0,32,32)
  StartDrawing(ImageOutput(0))
  Box(0,0,32,32,$D8FEFE)
StopDrawing()

b.LOGBRUSH
b\lbStyle = #BS_PATTERN
b\lbHatch = ImageID(0)
hBrush = CreateBrushIndirect_(b)

mi.MENUINFO
mi\cbSize = SizeOf(MENUINFO)
mi\fMask = #MIM_STYLE |#MIM_BACKGROUND |#MIM_APPLYTOSUBMENUS
mi\dwStyle = #MNS_NOCHECK
mi\hbrBack = hBrush


OpenWindow(1,0,0,640,480,"",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)

hMenu=CreateMenu(0, WindowID(1))
MenuTitle("Data")
MenuItem(1, "Open")
MenuItem(2, "Save")
MenuItem(3, "Save as")
hSubMenu = OpenSubMenu("Recent files")
MenuItem(5, "File 1")
MenuItem(6, "File 2")
CloseSubMenu()
MenuItem(4, "Quit")

SetMenuInfo_(hMenu,mi)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Egypt my love
User avatar
Lord
Addict
Addict
Posts: 900
Joined: Tue May 26, 2009 2:11 pm

Re: Remove space for checkmarks in front of menu item?

Post by Lord »

Hello Rashad!

Another nice piece of code.
Thank you. I may become handy some day.
Image
Post Reply