Results 1 to 5 of 5

Thread: Mouse_Click

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Does anyone know the API to detect which button has been press. I need an API because, I need to click anywhere on the screen, which does not have to be on the VB Application.

    Please send me a code sample.

    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    the SetCapture API will make windows send all mouse events to one window, ReleaseCapture sets it back to the window it's over, but whenever a mouse event is fired and code is executed the capture will be relesed.

    here's the declorations

    Code:
    Public Declare Function SetCapture Lib "user32" Alias "SetCapture" (ByVal hwnd As Long) As Long
    
    Public Declare Function ReleaseCapture Lib "user32" Alias "ReleaseCapture" () As Long
    set the capture to Command1 with

    Code:
    SetCapture Command1.hWnd

    If theres no code in you're mouse move event for your command button there's no need to set the muose captiure in it again, but if there's any code in your mousemove event make sure you set the capture there as well, you also need to set the capture at the end of your click dblClick, mouseup and mousedown events to keep the messages being sent.

    to release it just use

    Code:
    ReleaseCapture
    on it's own.

    setting the capture to a command button will cause vb to raise it's mouse events to that command button wherever the mouse is on the screen. N.B. if you set the capture to an object that is invisible it will majicly become visible.

    hope this helps.


  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Thanks Sam!

    I didn't explain myself too clear. Do you know of a way to extend the mouse_move event to all other application and then grab the handle where ever the point is residing on.

    Keep in mind, I am not interest in using a timer.

    You code is and will be appreciated.

    Thanks

  4. #4
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134
    Paste tihs to a module:

    ----START----
    Option Explicit

    Type POINTAPI 'Declare types
    x As Long
    y As Long
    End Type

    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long 'Declare API

    ---END---

    If you don't want to use a timer then check whenever you want. It gives you the coordinates relative to the points in screen.
    Jorge Ledo
    [email protected]
    Portugal were the sun allways shine... for programmers.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Thanks for replying my friend.

    But will this show me the handle as I move my pointer from application to application.

    I am looking for something where, as I move my pointer, it will show the handle in a label or handle.

    Yes, I am not looking to use a timer.

    Thank You.

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