wraithdu Posted January 28, 2009 Posted January 28, 2009 Since I recently improved my toolbar button hiding function, I decided it would be nice to have as a UDF as well. With this UDF you can add minimize-to-tray functionality to your GUI very easily. There are a few caveats. For it to work as a UDF, these options must be set, and ARE set automatically - Opt("GUIOnEventMode", 1); OnEvent mode Opt("TrayOnEventMode", 1); ditto Opt("TrayMenuMode", 1); no default tray menu (no pause or exit), user can still create custom menu Opt("GUIEventOptions", 1); minimize, maximize, and restore only send notifications, we handle the actions and these events registered - ; set min/max/restore events GUISetOnEvent($GUI_EVENT_MINIMIZE, "_OnEventMinimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_OnEventMaximize") GUISetOnEvent($GUI_EVENT_RESTORE, "_OnEventRestore") Lastly, if you go with the option to show / hide the tray icon also, it looks better to set the #NoTrayIcon option initially in your script, unless your GUI is starting minimized, in which case you'll want to omit that option. Example - #include <_MinimizeToTray.au3> #include <WindowsConstants.au3> Global $bExit = False Global $gui = GUICreate("_MinimizeToTray Example", 400, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX)) _MinimizeToTray($gui) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState() While 1 Sleep(1000) WEnd Func _Exit() If Not $bExit Then $bExit = True WinSetTitle($gui, "", "_MinimizeToTray Example w/ Tray Icon") _MinimizeToTray($gui, True) TraySetState(2) Else Exit EndIf EndFunc_MinimizeToTray.au3
CodyBarrett Posted April 5, 2009 Posted April 5, 2009 nice UDF! [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now