Sign in to follow this  
Followers 0
AndyS01

Add a bold non clickable header to a first level menu

2 posts in this topic

I'm building a system menu that has 2 groups of selections and I want to add a header for each group but I cannot see how to do it.
 
I'd like to make them bold and also not clickable (like the separator line is)
 
I tried _GUICtrlMenu_SetItemHighlighted() but that didn't work.
 
Here is my test code:
Opt("GUICloseOnESC", 1) ; ESC closes GUI
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Opt('MustDeclareVars', 1)
OnAutoItExitRegister("ExitStageLeft")

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Global $hMainWin

_Main()

Func _Main()

    $hMainWin = GUICreate("test", 300, 300)

    create_menus()

    GUISetState()
    GUISetOnEvent($GUI_EVENT_CLOSE, 'ExitStageLeft')

    While (1)
        Sleep(500)
    WEnd

EndFunc   ;==>_Main

Func ExitStageLeft()
    Exit (1)
EndFunc   ;==>ExitStageLeft

Func create_menus()
    Local $iID_Menu, $id1, $id2

    $iID_Menu = GUICtrlCreateMenu("&Test")

    GUICtrlCreateMenuItem("Some entry", $iID_Menu)
    GUICtrlCreateMenuItem("another entry", $iID_Menu)
    GUICtrlCreateMenuItem("", $iID_Menu)

    $id1 = GUICtrlCreateMenuItem("Header 1:", $iID_Menu)
    GUICtrlCreateMenuItem("Item 1", $iID_Menu)
    GUICtrlCreateMenuItem("Item 2", $iID_Menu)
    GUICtrlCreateMenuItem("", $iID_Menu)

    _GUICtrlMenu_SetItemHighlighted($iID_Menu, $id1, True)

    $id2 = GUICtrlCreateMenuItem("Header 2:", $iID_Menu)
    GUICtrlCreateMenuItem("Item 3", $iID_Menu)
    GUICtrlCreateMenuItem("Item 4", $iID_Menu)

EndFunc   ;==>create_menus

 

Share this post


Link to post
Share on other sites



I'm not sure if there is an easy way in doing this. I don't think so, but maybe with 'modern menu UDF'.

But why not this way:

Opt("GUICloseOnESC", 1) ; ESC closes GUI
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Opt('MustDeclareVars', 1)
OnAutoItExitRegister("ExitStageLeft")

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Global $hMainWin

_Main()

Func _Main()

$hMainWin = GUICreate("test", 300, 300)

create_menus()

GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, 'ExitStageLeft')

While (1)
Sleep(500)
WEnd

EndFunc ;==>_Main

Func ExitStageLeft()
Exit (1)
EndFunc ;==>ExitStageLeft

Func create_menus()
Local $iID_Menu, $id1, $id2

$iID_Menu = GUICtrlCreateMenu("&Test")

GUICtrlCreateMenuItem("Some entry", $iID_Menu)
GUICtrlCreateMenuItem("another entry", $iID_Menu)
GUICtrlCreateMenuItem("", $iID_Menu)

$id1 = GUICtrlCreateMenu("Header 1:", $iID_Menu)
GUICtrlCreateMenuItem("Item 1", $id1)
GUICtrlCreateMenuItem("Item 2", $id1)

GUICtrlCreateMenuItem("", $iID_Menu)

$id2 = GUICtrlCreateMenu("Header 2:", $iID_Menu)
GUICtrlCreateMenuItem("Item 3", $id2)
GUICtrlCreateMenuItem("Item 4", $id2)

EndFunc ;==>create_menus

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0