checking if mouse hovered?
Posted: Fri Oct 31, 2008 11:07 pm
I want to display a small window when the user mouse moves over the tray icon... I don't want to use DirectX to get mouse position...
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
SysTrayIconToolTip(#SysTrayIcon, Text$)
Code: Select all
GetCursorPos_(mouse.POINT)
mx=mouse\x ; Mouse X position on screen.
my=mouse\y ; Mouse Y position on screen.
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - SysTray example file
;
; (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;
If OpenWindow(0, 100, 150, 300, 100, "PureBasic - SysTray Example", #PB_Window_SystemMenu)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
; .ico format is available only on Windows
IconName$ = #PB_Compiler_Home+"examples\sources\Data\CdPlayer.ico"
CompilerElse
IconName$ = #PB_Compiler_Home+"examples\sources\Data/Drive.bmp"
CompilerEndIf
AddSysTrayIcon(1, WindowID(0), LoadImage(0, IconName$))
AddSysTrayIcon(2, WindowID(0), LoadImage(1, IconName$))
SysTrayIconToolTip(1, "Icon 1")
SysTrayIconToolTip(2, "Icon 2")
Repeat
Event = WaitWindowEvent()
;----------------------------------------
; undocumented unsupported hack
;----------------------------------------
Select Event
Case #WM_USER + 11478
If EventlParam() = #WM_MOUSEMOVE
affectedicon = EventwParam()
Debug "mouse moved on systray icon " +Str(affectedicon)
EndIf
EndSelect
;----------------------------------------
; end hack
;----------------------------------------
If Event = #PB_Event_SysTray
If EventType() = #PB_EventType_LeftDoubleClick
MessageRequester("SysTray", "Left DoubleClick on SysTrayIcon "+Str(EventGadget()),0)
ChangeSysTrayIcon (EventGadget(), LoadImage(0, IconName$))
SysTrayIconToolTip(EventGadget(), "Changed !")
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf