Detecting Mouse Pos on other apps 
Author Message
 Detecting Mouse Pos on other apps

Hi All,
I'm using Paul Kuliniewicz's (vbapi.com) handy solution for detecting
the window title based on the position of the mouse pointer, especially
when the VB app doesn't have the focus. I'm using this technique to
shrink my app's form size when the mouse is detected off the form, and
to enlarge it when it's on the form.

Unfortunately, all controls on my form have no window title, i.e. only
when the mouse is over the form (or title bar) itself is the form's
title returned; otherwise a blank title name is returned. So I've
resorted to enlarging my form when when the window name is "My App" or
when it's "". Well, several mouse positions also create a null window
title: the Task Bar, the Tray Menu, application Menus, etc. so app
unexpectedly enlarges.

How can I truly detect when the mouse position is anywhere over my form?

TIA,
Simon



Fri, 07 May 2004 23:59:18 GMT  
 Detecting Mouse Pos on other apps
It sounds like you're trying to do this in a fairly awkward way.  You might
want to consider using something like...

Private Function IsPointerOverWindow(Optional ByVal WhichWindow As Long) As
Boolean
    If WhichWindow = 0 Then
        ' Set default
        WhichWindow = Me.HWnd
    End If

    Dim Window As Long
    Dim PT As POINTAPI

    GetCursorPos PT
    Window = WindowFromPoint(PT.X, PT.Y)

    If WhichWindow = Window Then
        ' Window is the form
        IsPointerOverWindow = True
    ElseIf IsChild(WhichWindow, Window) Then
        ' Window is a child
        IsPointerOverWindow = True
    End If
End Function

If you call this function from within a form (without passing a parameter),
it will return True if the pointer is over the form.

Murphy McCauley
www.fullspectrum.com/deeth

Quote:

>Hi All,
>I'm using Paul Kuliniewicz's (vbapi.com) handy solution for detecting
>the window title based on the position of the mouse pointer, especially
>when the VB app doesn't have the focus. I'm using this technique to
>shrink my app's form size when the mouse is detected off the form, and
>to enlarge it when it's on the form.

>Unfortunately, all controls on my form have no window title, i.e. only
>when the mouse is over the form (or title bar) itself is the form's
>title returned; otherwise a blank title name is returned. So I've
>resorted to enlarging my form when when the window name is "My App" or
>when it's "". Well, several mouse positions also create a null window
>title: the Task Bar, the Tray Menu, application Menus, etc. so app
>unexpectedly enlarges.

>How can I truly detect when the mouse position is anywhere over my form?

>TIA,
>Simon



Sat, 08 May 2004 22:16:47 GMT  
 Detecting Mouse Pos on other apps
Thanks Murphy!
I modified my code and it works great. I owe you a beer...
Regards,
Simon
-----
remove NOSPAM
Quote:

> It sounds like you're trying to do this in a fairly awkward way.  You might
> want to consider using something like...

> Private Function IsPointerOverWindow(Optional ByVal WhichWindow As Long) As
> Boolean
>     If WhichWindow = 0 Then
>         ' Set default
>         WhichWindow = Me.HWnd
>     End If

>     Dim Window As Long
>     Dim PT As POINTAPI

>     GetCursorPos PT
>     Window = WindowFromPoint(PT.X, PT.Y)

>     If WhichWindow = Window Then
>         ' Window is the form
>         IsPointerOverWindow = True
>     ElseIf IsChild(WhichWindow, Window) Then
>         ' Window is a child
>         IsPointerOverWindow = True
>     End If
> End Function

> If you call this function from within a form (without passing a parameter),
> it will return True if the pointer is over the form.

> Murphy McCauley
> www.fullspectrum.com/deeth


> >Hi All,
> >I'm using Paul Kuliniewicz's (vbapi.com) handy solution for detecting
> >the window title based on the position of the mouse pointer, especially
> >when the VB app doesn't have the focus. I'm using this technique to
> >shrink my app's form size when the mouse is detected off the form, and
> >to enlarge it when it's on the form.

> >Unfortunately, all controls on my form have no window title, i.e. only
> >when the mouse is over the form (or title bar) itself is the form's
> >title returned; otherwise a blank title name is returned. So I've
> >resorted to enlarging my form when when the window name is "My App" or
> >when it's "". Well, several mouse positions also create a null window
> >title: the Task Bar, the Tray Menu, application Menus, etc. so app
> >unexpectedly enlarges.

> >How can I truly detect when the mouse position is anywhere over my form?

> >TIA,
> >Simon



Sun, 09 May 2004 08:22:21 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detecting Mouse in NON VB app!?

2. Detecting Mouse Click in Non-VB or VB app (in VB 6)

3. Determining Mouse pos over scrollbar?

4. Determining Mouse pos over scrollbar?

5. Determining Mouse pos over scrollbar?

6. mouse pos

7. Getting mouse pos

8. mouse move event detected with no mouse movement?!?

9. How to detect Desqview and others multitask

10. VB5.0 for POS Credit Card processing app.

11. Making databases R/W to my app, R/O to others

12. Detecting Mouse Position x y

 

 
Powered by phpBB® Forum Software