Results 1 to 8 of 8

Thread: MouseMove question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849
    I want to know how can I use the mousemove effect.
    And also how to disable the things it did.
    can you help me?
    Dekel C.

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    what exactly do you mean?

    the mouse move effect launches when someone puts there mouse over the object (text box, label, command button, image, etc.)

    lets say you have a label and a form put this code in and see what happens:

    Code:
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.BackColor = vbRed
    Form1.BackColor = vbRed
    End Sub
    
    Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.BackColor = vbBlue
    Form1.BackColor = vbYellow
    End Sub
    NXSupport - Your one-stop source for computer help

  3. #3
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Or do you mean setting the mouse pos?
    Code:
    'Mouse Move
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    
    Public Sub Command1_Click()
       'Set Cursor Pos
        SetCursorPos 680, 480
    End Sub
    Please provide more detail if that't not what you are looking for.

    Gl,
    D!m
    Dim

  4. #4
    Guest
    To disablew the mouse move event, you would have to subclass your App.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849
    I meant what dimava said.
    But what if I want that after the mouse is no longer on
    the label, the settings will resume?
    Dekel C.

  6. #6
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Three ideas:

    #1: use the SetCapture API

    #2: if you have vb5 or vb6, look in the vb samples for the activex control projects and look in them for examples on the SetCapture API

    #3: go to msdn.microsoft.com and download the SoftButtons sample code for VB
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849
    I don't think I need to use an api.
    I just want to know how to change the settings
    when the mouse is no longer on the button.
    Dekel C.

  8. #8
    Guest
    If you have mnay controls on your Form and do not want to add the same code to all their MouseMove events, simply use the following instead.

    Add it to a Form with a Timer and a CommandButton.
    Code:
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    
    
    Private Sub Form_Load()
        Timer1.Interval = 1
    End Sub
    
    Private Sub Timer1_Timer()
    
        Dim PT As POINTAPI
        Dim WND As Long
        
        'Get the Cursor postion and the hWnd it's on
        GetCursorPos PT
        WND = WindowFromPoint(PT.x, PT.y)
        
        'Check if the hWnd the mouse is over is Command1
        If WND = Command1.hWnd Then Command1.Caption = "Mouse is on Command1" Else Command1.Caption = "Mouse is not on Command1"
        
    End Sub

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