Jump to content
Sign in to follow this  
billthecreator

GUi minimize to tray

Recommended Posts

smashly

Hi,

Don't know if it helps...

I did an on event mode 1 example of min to tray, tray to gui.

(since the other example is in on event mode 0)

#include <GuiConstants.au3>
#Include <Constants.au3>

Opt("TrayMenuMode",1)
Opt("TrayOnEventMode",1)
Opt("GUIOnEventMode", 1)

;----- Gui ----
$Main = GuiCreate("Minimize To Tray", 300, 200, -1, -1) 
GUISetOnEvent($GUI_EVENT_MINIMIZE, 'GuiEvent')
GUISetOnEvent($GUI_EVENT_CLOSE, 'GuiEvent')
GUISetState(@SW_SHOW, $Main)

;------ Tray Menu ----
$Show = TrayCreateItem("Show Gui")
TrayItemSetOnEvent(-1, 'TrayEvent')
TrayCreateItem("")
$Exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, 'TrayEvent')
TraySetState(2)

While 1
    Sleep(10)
WEnd

Func GuiEvent()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
            GUISetState(@SW_HIDE, $Main)
            TraySetState(1)     
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE 
            Exit
    EndSelect       
EndFunc


Func TrayEvent()
    Select
        Case @TRAY_ID = $Show 
                GUISetState(@SW_SHOW, $Main)
                GUISetState(@SW_RESTORE, $Main)             
                TraySetState(2)         
        Case @TRAY_ID = $Exit
                Exit
    EndSelect       
EndFunc

Cheers

Edited by smashly

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  

×