|
-
Sep 9th, 2012, 03:51 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] VB6 - Mouse move on Shape1
I want to execute an instruction each time the mouse moves over a shape (a rectangle).
Picture1 control, for example, has that property. But when I try to find the same option in shape it doesn't exists.
How can I solve this situation?
I've thought about creating a matrix of coordenates (x,y) and if the mouse position is at some point of those coordinates then, execute the instruction. In any case, explain me how can I accomplish that.
-
Sep 9th, 2012, 05:10 AM
#2
Re: VB6 - Mouse move on Shape1
Need to check coordinates on Form_Move event (or relative container of the shape).
Code:
Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X >= Shape1.Left And X <= (Shape1.Left + Shape1.Width) And Y >= Shape1.Top And Y <= (Shape1.Top + Shape1.Height) Then
Label1.Caption = "IN"
Else
Label1.Caption = "OUT"
End If
End Sub
-
Sep 9th, 2012, 05:12 AM
#3
Re: VB6 - Mouse move on Shape1
 Originally Posted by Jose_VB
I've thought about creating a matrix of coordenates (x,y) and if the mouse position is at some point of those coordinates then, execute the instruction. In any case, explain me how can I accomplish that.
Try this
Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Const x1 As Single = 1000
Const x2 As Single = 4000
Const y1 As Single = 1000
Const y2 As Single = 4000
If X > x1 And X < x2 And Y > y1 And Y < y2 Then
Me.Caption = "moving inside region"
Else
Me.Caption = "moving outside region"
End If
End Sub
-
Sep 9th, 2012, 11:07 AM
#4
Re: VB6 - Mouse move on Shape1
from 4x2y's example
Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim x1 As Single, x2 As Single
Dim y1 As Single, y2 As Single
x1 = Shape1.Left
x2 = Shape1.Left + Shape1.Width
y1 = Shape1.Top
y2 = Shape1.Top + Shape1.Height
If X > x1 And X < x2 And Y > y1 And Y < y2 Then
Me.Caption = "moving inside region"
Else
Me.Caption = "moving outside region"
End If
End Sub
-
Sep 9th, 2012, 12:28 PM
#5
Thread Starter
Hyperactive Member
Re: VB6 - Mouse move on Shape1
Thank you very much to all.
It works perfectly.
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
|