Page 1 of 1

checking if mouse hovered?

Posted: Fri Oct 31, 2008 11:07 pm
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...

Posted: Fri Oct 31, 2008 11:15 pm
by ts-soft

Code: Select all

SysTrayIconToolTip(#SysTrayIcon, Text$)
?

Posted: Fri Oct 31, 2008 11:20 pm
by funnyguy
No, I want to display my own window when the tooltip appears....

Re: checking if mouse hovered?

Posted: Sat Nov 01, 2008 6:58 am
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.

Posted: Sat Nov 01, 2008 2:26 pm
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