News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

API capture functions to make a button

Started by nandagopal, May 18, 2009, 04:29 PM

Previous topic - Next topic

nandagopal

When the mouse moves over the button, use the GetCapture function to see what window has the mouse captured. If it is not this button, use SetCapture to capture mouse events.

When the MouseMove event occurs and the cursor has left the button's area, use ReleaseCapture to release the capture.


Private Sub Check1_MouseMove(Index As Integer, Button As _
    Integer, Shift As Integer, X As Single, Y As Single)
    If (X < 0) Or (Y < 0) Or (X > Check1(Index).Width) Or _
        (Y > Check1(Index).Height) Then
        '        ' the MOUSELEAVE pseudo-event
        ReleaseCapture
        '        ' in this example revert the caption to
        ' normal
        Check1(Index).Font.Bold = False
        Check1(Index).ForeColor = vbBlack
        '
    ElseIf GetCapture() <> Check1(Index).hwnd Then
        '        ' the MOUSEENTER pseudo-event
        SetCapture Check1(Index).hwnd

        Check1(Index).Font.Bold = True
        Check1(Index).ForeColor = vbRed
    End If
End Sub

Private Sub Command1_MouseMove(Index As Integer, Button As _
    Integer, Shift As Integer, X As Single, Y As Single)

    If (X < 0) Or (Y < 0) Or (X > Command1(Index).Width) Or _
        (Y > Command1(Index).Height) Then
        '        ' the MOUSELEAVE pseudo-event
        ReleaseCapture
        '        ' in this example revert the caption to
        ' normal

        Command1(Index).Font.Bold = False
        '
    ElseIf GetCapture() <> Command1(Index).hwnd Then
        '        ' the MOUSEENTER pseudo-event
        SetCapture Command1(Index).hwnd

        Command1(Index).Font.Bold = True
    End If
End Sub