CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Mouse & Handles

  1. #1
    Guest

    Mouse & Handles

    I was wondering how to get the handle of a window that the mouse is currently over. If anyone has any ideas/suggestions i'd appreciate your response.

    Thank You.
    Lynx


  2. #2
    Join Date
    Dec 1999
    Location
    Curitiba - Paraná - Brazil
    Posts
    6

    Re: Mouse & Handles

    You may try this code:

    Paste into your module


    public Type POINTAPI
    x as Long
    y as Long
    End Type

    public Declare Function WindowFromPoint Lib "user32" (byval xPoint as Long, byval yPoint as Long) as Long
    public Declare Function GetCursorPos Lib "user32" (lpPoint as POINTAPI) as Long




    This will get the handle of the window that the mouse is over, but how can i take this event? As a solution to this problem I use the MouseUp Event of the Form, as described above:


    private Sub Form1_MouseUp(...)
    Dim lhWnd as Long
    Dim lDummy as Long

    Dim xCursor as POINTAPI

    lDummy=GetCursorPos(xCursor)

    'This line will return the handle
    lhWnd=WindowFromPoint(xCursor.x,xCursor.y)
    End Sub




    so, when the user click in your window and drag releasing the mouse over other window, the application will get the handle of window where are the mouse pointer.

    (sorry about my english)

    Vanclei Matheus
    [email protected]
    Techno Dreamer

  3. #3
    Guest

    Re: Mouse & Handles

    Hey that worked, thanks!

    now i just want to know how to be able to do that by dragging and releasing an icon over the desired window.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured