Problem using GetFocus/LostFocus on SysTray
Posted: Fri Jul 24, 2009 5:08 am
I am trying to catch the get focus and lost focus event of the system tray icon.
It looks like no response at all.
Is it suppose no such events on system tray at all?
It looks like no response at all.
Is it suppose no such events on system tray at all?
Code: Select all
If OpenWindow(0, 100, 150, 300, 100, "PureBasic - SysTray Example", #PB_Window_SystemMenu)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
IconName$ = "Data\CdPlayer.ico"
CompilerElse
IconName$ = "Data/Drive.bmp"
CompilerEndIf
AddSysTrayIcon(1, WindowID(0), LoadImage(0, IconName$))
SysTrayIconToolTip(1, "Icon 1")
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_SysTray
If EventType() = #PB_EventType_Focus
MessageRequester("SysTray", "SysTrayIcon "+Str(EventGadget())+" is gained focused.",0)
EndIf
If EventType() = #PB_EventType_LostFocus
MessageRequester("SysTray", "SysTrayIcon "+Str(EventGadget())+" is lost focused.",0)
EndIf
If EventType() = #PB_EventType_LeftDoubleClick
MessageRequester("SysTray", "Left DoubleClick on SysTrayIcon "+Str(EventGadget()),0)
EndIf
If EventType() = #PB_EventType_RightClick
MessageRequester("SysTray", "RightClick on SysTrayIcon "+Str(EventGadget()),0)
ChangeSysTrayIcon (EventGadget(), LoadImage(2, IconName$))
SysTrayIconToolTip(EventGadget(), "Changed !")
EndIf
If EventType() = #PB_EventType_LeftClick
MessageRequester("SysTray", "LeftClick on SysTrayIcon "+Str(EventGadget()),0)
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf