|
-
Feb 26th, 2000, 01:14 AM
#1
Thread Starter
Addicted Member
Hi,
I'm developing an Activex Command Button like IE Button. It's my first experience in making OCX and I'm in trouble.
When the mouse is over the button I draw the frame around it (using the MouseMove method), but when the mouse is out of the control I need to erase that Frames. My problem is how to detect when the mouse IS OUT of the button. Do you know how can I do that?
Thank you for any help
Michel Junior
[email protected]
-
Feb 26th, 2000, 01:41 AM
#2
Member
-
Feb 26th, 2000, 03:20 AM
#3
Member
Sorry I didn't read your problem carefully. I realized that form_MouseMove will probally won't work because you are making a user control. Let think about it for a bit and I'll try to reply later.
-
Feb 26th, 2000, 04:35 AM
#4
Member
OK, I think I have found a solution for you.
In the usercontrol_mousemove event there X and Y arguments. You can use these coordinates to enable your frame around the control area. Also to erase your frame.
For example,
(Left Side of the control)
When the mouse pointer is between the X coordinates 0 to 15 then erase the frame. When X is > 15 then draw frame.
Find the size of the control (height and width) and set your limits, using X and Y arguments, to draw and erase the frame on your form.
Also note that if you use a frame object to make boarder around the usercontrol, it will cause the usercontrol_mousemove event not to trigger Because the mouse pointer is in the frame1 object. Try drawing lines instead just to be safe.
Edited by Sacred_knight on 02-26-2000 at 04:40 PM
-
Feb 26th, 2000, 05:51 AM
#5
Junior Member
Hi,
I don't know if you can use API calls when making an ocx, but you can try this: it's a sample to give some "MouseOut" property to a control (note the fact that this control must have the hWnd property).
You can try this with a command button (Command1):
'General declarations
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
'Command1 MouseMove
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean
MouseEnter = (0 <= X) And (X <= Command1.Width) And (0 <= Y) And (Y <= Command1.Height)
If MouseEnter Then
Me.Caption = "Mouse In Button!"
SetCapture Command1.hWnd
Else
Me.Caption = "Mouse Out!"
ReleaseCapture
End If
End Sub
P.S: if this does not work in your ocx, I hope you or someone else will find this code usefull...
Claude
-
Feb 26th, 2000, 07:03 PM
#6
New Member
Clear Up
Claudi... thank u for ur post. i too needed to figure out how to detect mouse in and mouse out events. i've copied ur code n used it, but the problem is that i don't understand ONE single line. If you could please ******** what the line means or just rewrite it in newbie terms cause i just don't understand what the line means. the line is:
MouseEnter = (0 <= X) And (X <= Command1.Width) And (0 <= Y) And (Y <= Command1.Height)
...so yea. thank u in advance 
Edited by evoluzion on 02-28-2000 at 08:33 PM
-
Mar 19th, 2000, 04:57 AM
#7
Member
Explanation
This line returns a boolean value if the mouse cursor is in the button.
MouseEnter = (0 <= X) And (X <= Command1.Width)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The X value is between 0 and the width of the button
And (0 <= Y) And (Y <= Command1.Height)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Y value is between 0 and the height. If all this is true, then MouseEnter is True and the cursor is in the button.
--Mike Wellems
P.S. Thanks for the code, Claudi. This should be an official VB-World tip.
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
|