checking if mouse hovered?
checking if mouse hovered?
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...
Code: Select all
SysTrayIconToolTip(#SysTrayIcon, Text$)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: checking if mouse hovered?
> I don't want to use DirectX to get mouse position
Code: Select all
GetCursorPos_(mouse.POINT)
mx=mouse\x ; Mouse X position on screen.
my=mouse\y ; Mouse Y position on screen.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Your program can notice when the mouse pointer moves on a systray icon of yours using this (undocumented and unsupported windows only) technique:
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
BERESHEIT