home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,391 of 10,840   
   Shell to stated...and I   
   Re: Mouse location   
   23 Jan 07 09:09:05   
   
   From: drshell@mindspring.com   
      
   In response to the post:   
    On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"   
    stated...and I replied:   
      
   >Hi all,   
   >   
   >My development environment is VB 6.0, and my OS is winxp.  I would like to   
   know how to find the mouse location at a control when the mouse is point at   
   that control. The problem is that the mouse "whatever" events will not fire   
   since the mouse is hjhack    
   by other control. Anyway, I have the following code and I can check is the   
   mouse over the control or not, however, I cannot find out where the mouse   
   location at that control.   
   >   
   >Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As   
   Long   
   >Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long,   
   ByVal yPoint As Long) As Long   
   >   
   >   
   >private sub mouseChecker()   
   >     Dim pnt As POINTAPI   
   >     Dim ConvertX As Double   
   >    GetCursorPos pnt   
   >  If WindowFromPoint(pnt.x, pnt.y) = Me.control1.hWnd Then   
   >       'I cannot find any method in finding the mouse location in that Visual   
   basic control.   
   >   
   >  End If   
   >end sub   
   >   
   >   
   >   
   >thanks   
   >Egghead   
      
      
   Try this (air code)   
      
   'begin code   
   Type POINTAPI   
       X As Long   
       Y As Long   
   End Type   
      
   Type RECT   
       Left   As Long   
       Top    As Long   
       Right  As Long   
       Bottom As Long   
   End Type   
      
   Type WINDOWPLACEMENT   
       Length           As Long   
       flags            As Long   
       ShowCmd          As Long   
       ptMinPosition    As POINTAPI   
       ptMaxPosition    As POINTAPI   
       rcNormalPosition As RECT   
   End Type   
      
   Declare Function GetCursorPos Lib "user32" ( _   
       lpPoint As POINTAPI) As Long   
      
   Declare Function GetWindowPlacement Lib "user32" ( _   
       ByVal hwnd As Long, _   
       lpwndpl As WINDOWPLACEMENT) As Long   
      
   Public Function PointsToMe() As Boolean   
   Dim WinPos As WINDOWPLACEMENT   
   Dim Point As POINTAPI, lResult As Long   
      
       lResult = GetCursorPos(Point)   
      
       lResult = GetWindowPlacement(Me.hwnd, WinPos)   
      
       If Point.X >= WinPos.rcNormalPosition.Left And _   
          Point.X <= WinPos.rcNormalPosition.Right And _   
          Point.Y >= WinPos.rcNormalPosition.Top And _   
          Point.Y <= WinPos.rcNormalPosition.Bottom Then _   
           PointsToMe = True   
   End Function   
   'end air code   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca