Results 1 to 4 of 4

Thread: Control help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    64

    Post

    ok, with most controls, they have; MouseDown, MouseMove, and MouseUp. that doesn't do me much good, is there anyway to have it act as a MouseEnter/MouseExit event? Please help.

    Example would be, you put your mouse over a picbox, and it changes to a different picture, move the mouse off the picbox, and it would change back.

  2. #2
    Lively Member
    Join Date
    May 1999
    Location
    Vancouver, BC, Canada
    Posts
    84

    Post

    Here's a bit of code that changes the caption of a command button as the mouse is moved onto & off the button. Should be the same for a PictureBox control.


    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Command1.Caption = "ON"
    End Sub

    Private Sub Form_MouseMove(Button As Integer
    , Shift As Integer, X As Single, Y As Single)
    Command1.Caption = "OFF"
    End Sub

  3. #3
    Guest

    Post

    That only works if you move the mouse over the form(after you where above the button) it doesn't work if you move over another control(or move real fast).

    The only decent way i found to this kinda thing is with the GetCurserPos api.



    ------------------

    Vincent van den Braken
    EMail: [email protected]
    ICQ: 15440110
    Homepage: http://www.azzmodan.demon.nl




  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    You can use the SetCapture API function. Here's an example using a command button:

    'Form Code
    Option Explicit

    Private Declare Function SetCapture _
    Lib "user32" ( _
    ByVal hwnd As Long) As Long

    Private Declare Function ReleaseCapture _
    Lib "user32" () As Long

    Private blnHasCapture As Boolean

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If blnHasCapture = False Then
    Call SetCapture(Command1.hwnd)
    blnHasCapture = True
    End If
    If (X < 0 Or X > Command1.Width) Or (Y < 0 Or Y > Command1.Height) Then
    Command1.Caption = "Off"
    Call ReleseCapture()
    blnHasCapture = False
    Else
    Command1.Caption = "On"
    End If
    End Sub

    Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If blnHasCapture Then
    Call SetCapture(Command1.hwnd)
    End If
    End Sub

    Good luck!




    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



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