|
-
Oct 4th, 2000, 02:46 PM
#1
Thread Starter
Fanatic Member
I want to know how can I use the mousemove effect.
And also how to disable the things it did.
can you help me?
-
Oct 4th, 2000, 03:16 PM
#2
Frenzied Member
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
-
Oct 4th, 2000, 03:26 PM
#3
Fanatic Member
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
-
Oct 4th, 2000, 05:16 PM
#4
To disablew the mouse move event, you would have to subclass your App.
-
Oct 5th, 2000, 07:22 AM
#5
Thread Starter
Fanatic Member
I meant what dimava said.
But what if I want that after the mouse is no longer on
the label, the settings will resume?
-
Oct 5th, 2000, 08:04 AM
#6
Frenzied Member
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
-
Oct 5th, 2000, 12:27 PM
#7
Thread Starter
Fanatic Member
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.
-
Oct 5th, 2000, 02:38 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|