Jump to content

MenuItem check marks not being displayed


Recommended Posts

For some reason, I can't seem to get little ticks in the Menu bar. The menuitem will trigger the event when clicked but it won't add the check mark to the menubar (it does to the tray without problem) so I'm wondering if its a problem with Autoit 3.2.12.0 or some Windows XP setting I've missed. Here's some code to get an idea:

CODE

Func MainGUI()

$h_MainGUI = GUICreate($s_Title, 800, 630, $i_WinXPos, $i_WinYPos)

GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit", $h_MainGUI)

Local $h_OptionsMenu = GUICtrlCreateMenu("&Options")

Local $h_AutoStartMenuItem = GUICtrlCreateMenuItem("Auto &Start", $h_OptionsMenu)

GUICtrlSetOnEvent($h_AutoStartMenuItem, "OnAutoStart")

If $i_AutoStart = 0 Then

GUICtrlSetState($h_AutoStartMenuItem, $GUI_UNCHECKED)

Else

GUICtrlSetState($h_AutoStartMenuItem, $GUI_CHECKED)

EndIf

GUISetState(@SW_SHOW, $h_MainGUI)

EndFunc

Func OnAutoStart()

If $i_AutoStart = 0 Then

$i_AutoStart = 1

TrayItemSetState($h_AutoStartTrayItem, $TRAY_CHECKED)

GUICtrlSetState($h_AutoStartMenuItem, $GUI_CHECKED)

; modify registery here

Else

$i_AutoStart = 0

TrayItemSetState($h_AutoStartTrayItem, $TRAY_UNCHECKED)

GUICtrlSetState($h_AutoStartMenuItem, $GUI_UNCHECKED)

; modify registery here

EndIf

EndFunc

#cs

The tray code goes something like this and it works fine. As you can see, it's nearly identical to the menu code:

$h_AutoStartTrayItem = TrayCreateItem("Auto Start", $h_SettingsMenu)

TrayItemSetOnEvent($h_AutoStartTrayItem, "OnAutoStart")

If $i_AutoStart = 0 Then

TrayItemSetState($h_AutoStartTrayItem, $TRAY_UNCHECKED)

Else

TrayItemSetState($h_AutoStartTrayItem, $TRAY_CHECKED)

EndIf

#ce

Any ideas or obvious things I've overlooked?

Link to comment
Share on other sites

PartyPooper

Hi! Works fine for me:

#include <GUIConstantsEx.au3>

Opt("GuiOnEventMode", 1)

$h_MainGUI = GUICreate("Test GUI", 800, 630)
GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
    
Local $h_OptionsMenu = GUICtrlCreateMenu("&Options")
Local $h_AutoStartMenuItem = GUICtrlCreateMenuItem("Auto &Start", $h_OptionsMenu)
GUICtrlSetOnEvent(-1, "OnAutoStart")

If $i_AutoStart = 0 Then
    GUICtrlSetState($h_AutoStartMenuItem, $GUI_UNCHECKED)
Else
    GUICtrlSetState($h_AutoStartMenuItem, $GUI_CHECKED)
EndIf

GUISetState(@SW_SHOW, $h_MainGUI)
    
Do
    Sleep(100)
Until False

Func OnAutoStart()
    If BitAND(GUICtrlRead(@GUI_CtrlId), $GUI_CHECKED) Then
        GUICtrlSetState($h_AutoStartMenuItem, $GUI_UNCHECKED)
    Else
        GUICtrlSetState($h_AutoStartMenuItem, $GUI_CHECKED)
    EndIf
EndFunc

Func OnExit()
    Exit
EndFunc
Edited by rasim
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...