Page 1 of 1

Variant WindowMouseX()

Posted: Thu Aug 26, 2010 8:56 am
by blueznl

Code: Select all

global gs_windowmousedx.i, gs_windowmousedy.i

Procedure.i gs_windowmousex(windownr.i)                                               ; return window related mouse coordinate
  Protected wmx.i, dmx.i
  ;
  ; *** return window related mouse coordinate
  ;
  ; the normal windowmousex() returns -1 for any position outside the window, this returns a coordinate relative to the window interior
  ; no matter if the mouse is in- or outside the window
  ;
  wmx = WindowMouseX(windownr)
  dmx = DesktopMouseX()
  If wmx >= 0
    gs_windowmousedx = dmx-wmx
  EndIf
  ProcedureReturn DesktopMouseX()-gs_windowmousedx                  
EndProcedure

Procedure.i gs_windowmousey(windownr.i)                                               ; return window related mouse coordinate
  Protected wmy.i, dmy.i
  ;
  ; *** return window related mouse coordinate
  ;
  ; the normal windowmousex() returns -1 for any position outside the window, this returns a coordinate relative to the window interior
  ; no matter if the mouse is in- or outside the window
  ;
  wmy = WindowMouseY(windownr)
  dmy = DesktopMouseY()
  If wmy >= 0
    gs_windowmousedy = dmy-wmy
  EndIf
  ProcedureReturn DesktopMouseY()-gs_windowmousedy                  
EndProcedure