Jump to content

Tray Question


 Share

Recommended Posts

I want to know if I can have tray and GUI in the same while loop.

If possible can you please keep it simple since I already have a huge GUI loop and now my friend has decided he wants it also in the tray :)

While 1
   $GGM = GUIGetMsg()
Switch $GGM   
$TGM = TrayGetMsg()
    Select
        Case $MyGUI
                _MyGUIFunction()
        Case $TGM = $MyTray
                _MyTrayFunction()
EndSwitch
    EndSelect
WEnd

Thanks :)

Edited by LithiumLi
Link to comment
Share on other sites

I'd like to suggest using "TrayOnEventMode" or TrayItemSetOnEvent() instead of handling it from within a msg handling loop. If you're insisting to use it within a msg loop you can use the TrayGetMsg() function...

I know but can you provide example of using GUI + Tray while/loop please that is what I need.

Link to comment
Share on other sites

Opt('TrayMenuMode', 1)

Dim $hGUI, $bt
Dim $Frist, $SecondSub, $Third

$hGUI = GUICreate('Title', 400, 385)
$bt = GUICtrlCreateButton('Button&1', 170, 177, 60, 30)

$Frist = TrayCreateMenu('First')
$SecondSub = TrayCreateItem('SecondSub', $Frist)
$Third = TrayCreateItem('Third')

GUISetState()

While 1
    Local $msg = GUIGetMsg()
    Local $tMsg = TrayGetMsg()
    
    Switch $msg
        Case $bt
            MsgBox(0x40, 'Title', 'Button')
            
        Case -3
            ExitLoop
    EndSwitch
    
    Switch $tMsg
        Case $SecondSub
            MsgBox(0x40, 'Tray', 'SecondSub')
            
        Case $Third
            MsgBox(0x10, 'Tray', 'Third')
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit

Link to comment
Share on other sites

Opt('TrayMenuMode', 1)

Dim $hGUI, $bt
Dim $Frist, $SecondSub, $Third

$hGUI = GUICreate('Title', 400, 385)
$bt = GUICtrlCreateButton('Button&1', 170, 177, 60, 30)

$Frist = TrayCreateMenu('First')
$SecondSub = TrayCreateItem('SecondSub', $Frist)
$Third = TrayCreateItem('Third')

GUISetState()

While 1
    Local $msg = GUIGetMsg()
    Local $tMsg = TrayGetMsg()
    
    Switch $msg
        Case $bt
            MsgBox(0x40, 'Title', 'Button')
            
        Case -3
            ExitLoop
    EndSwitch
    
    Switch $tMsg
        Case $SecondSub
            MsgBox(0x40, 'Tray', 'SecondSub')
            
        Case $Third
            MsgBox(0x10, 'Tray', 'Third')
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit
Thanks very much ill try adding it in my script now :)
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...