Sign in to follow this  
Followers 0
PartyPooper

MenuItem check marks not being displayed

6 posts in this topic

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?

Share this post


Link to post
Share on other sites



No one?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Yep, works for me too - damn. Means more debugging for me as something is interferring :)

Thanks Rasim.

Share this post


Link to post
Share on other sites

Found the error - I declared $h_AutoStartMenuItem as both local and global - DUH!

Share this post


Link to post
Share on other sites

Hi!

There is a problem in (If $i_AutoStart =)


[center]I LOVE ALGERIA .... ;-)[/center]

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