Mouse Click API

Brett964
Brett964 used Ask the Experts™
on
Hi,
I need to know how to detect a mouse click using API.
I have dynamically created a commandbutton w/o events and I need to be able to tell if the button was clicked so I can tell the program what to do.  Unfortuantely it does not fit the architecture of the program to create a button with events, thats why I am asking this question.
Once I can detect if the button was clicked, I can check the coords (with I do know how to do) and determine if the button was clicked.
Sorry about the points, this is all I have.

Thanks!
Brett
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Team Lead
Commented:
Try use GetCursorPos API to get the mouse pointer position:

Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'redirect all mouse input to this form
    SetCapture Me.hwnd
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'Get the current cursor position
    GetCursorPos Pt
    Me.CurrentX = 0
    Me.CurrentY = 0
    'Clear the screen
    Me.Cls
    Me.Print "Cursor position:"
    'Print the mouse coördinates to the form
    Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
    Me.Print " (Press ALT-F4 to unload this form)"
    SetCapture Me.hwnd
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SetCapture Me.hwnd
End Sub

Author

Commented:
Awesome! I apologize for only having 40 points.

-Brett
Ryan ChongSoftware Team Lead

Commented:
Points is not everything, glad could make help :) cheers

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial