Switch between SysTray Icons?
Posted: Sat Sep 14, 2013 11:41 pm
Hi all. I was working on my program as usual, but have run into a small problem.
When I minimize my program, it should switch to icon5.ico. If the user double clicks the systray icon it should switch back to the original icon.ico. When double clicking maximize, the maximize code should only work once until it has been re-minimized.
If I did not explain well, I do apologize, and just ask if you want me to explain better! =)
Here is the part of the code that matters:
Thank you so much!
P.S. Ignore the microsoft anna stuff. I have that there as a test
When I minimize my program, it should switch to icon5.ico. If the user double clicks the systray icon it should switch back to the original icon.ico. When double clicking maximize, the maximize code should only work once until it has been re-minimized.
If I did not explain well, I do apologize, and just ask if you want me to explain better! =)
Here is the part of the code that matters:
Code: Select all
OpenWindowedScreen(WindowID(0), 100, 150, 300, 100, 1, 0, 0, 0)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
; .ico format is available only on Windows
IconName$ = "icon.ico"
IconName2$ = "icon5.ico"
CompilerElse
IconName$ = "icon5.ico"
CompilerEndIf
AddSysTrayIcon(1, WindowID(0), LoadImage(1, IconName$))
SysTrayIconToolTip(1, "Icon 1")
Repeat
ClearScreen(RGB(240, 240, 240))
Event = WaitWindowEvent()
ExamineKeyboard()
If Event = #PB_Event_MinimizeWindow
SetWindowState(0, #PB_Window_Minimize)
HideWindow(0, 1)
WindowShowBalloonTip(0, 1, "Test!", "Test!", 1)
Speak( "eSpeak-en" , "Program minimized successfully!" , 100, 2, 150) ; if the voice Espeak installed
Speak( "Microsoft Anna" , "Program minimized successfully!" , 100, 1, 0) ; if the voice Microsoft Anna installed
EndIf
If Event = #PB_Event_SysTray
If EventType() = #PB_EventType_LeftDoubleClick
ShowWindow(0, 1)
SetWindowState(0, #PB_Window_Normal)
SetWindowState(0, #PB_Window_WindowCentered)
SetWindowPos_(WindowID(0),#HWND_TOPMOST,WindowWidth(0)/2,WindowHeight(0)/2,300,150,#SWP_NOMOVE|#SWP_NOSIZE)
SysTrayIconToolTip(EventGadget(), "Changed!")
Speak( "eSpeak-en" , "Program maximized successfully!" , 100, 2, 150) ; if the voice Espeak installed
Speak( "Microsoft Anna" , "Program maximized successfully!" , 100, 1, 0) ; if the voice Microsoft Anna installed
EndIf
ChangeSysTrayIcon (EventGadget(), LoadImage(2, IconName2$))
EndIfP.S. Ignore the microsoft anna stuff. I have that there as a test