checking if mouse hovered?

Just starting out? Need help? Post your questions and find answers here.
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

checking if mouse hovered?

Post by funnyguy »

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...
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

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.
Image
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

Post by funnyguy »

No, I want to display my own window when the tooltip appears....
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: checking if mouse hovered?

Post by PB »

> 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

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
Post Reply