TboXx
03-27-2004, 12:00 PM
I use alot of MouseMove events in my project, but what event would i use to make sure the code executes only when the mouse is over the object and stops when it is off of it?,
Thanks:huh:
Thanks:huh:
MouseMoveTboXx 03-27-2004, 12:00 PM I use alot of MouseMove events in my project, but what event would i use to make sure the code executes only when the mouse is over the object and stops when it is off of it?, Thanks:huh: Gilad_r 03-27-2004, 12:13 PM doesn't MouseMove do that http://www.visualbasicforum.com/x_images/images/smilies/huh.gif TboXx 03-27-2004, 12:35 PM uhhhh, i was just checking your knowledge...nm i just was doing something stupid TboXx 03-27-2004, 12:44 PM well actually im trying to get a button to be visible while on it, but not when off of it. any ideas on how to do that? is there some sort of rolling off event? Deadalus 03-27-2004, 01:07 PM No, there isn't a 'MouseLeave' event, but you can catch the mouse going off a control using SetCapture. http://www.visualbasicforum.com/showthread.php?t=130788 TboXx 03-27-2004, 01:30 PM well it worked to an extent. it showed up but it never went away. Private Sub lblC_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) txtHelp.Text = "Select text forecolor" If cmdC.Visible = False Then SetCapture cmdC.hwnd 'Make the frame catch all mouse events cmdC.Visible = True ElseIf X < 0 Or X > cmdC.Width Or Y < 0 Or Y > cmdC.Height Then cmdC.Visible = False 'mouse is off button, make button invisible ReleaseCapture 'let mouse events be handled normally again End If End Sub Deadalus 03-27-2004, 01:47 PM Uh, you're using the mousemove of a label and setting capture to a button... TboXx 03-27-2004, 01:53 PM i need the button to be visible on contact with a label TboXx 03-27-2004, 02:17 PM Im not getting what to exchange out in your code to work with me. when i roll over a label, a button is visible. the button is right on top of the label. so once im off of the button, i need it to be invisible again. Deadalus 03-27-2004, 02:39 PM That they're on top of eachother makes it easier, because otherwise you would have to work around the fact that you can't set capture to a label. In the MouseMove event of the label, make the button visible. In the MouseMove event of the button, set capture to the button (meaning it will receive all mouse events now, regardless of where the mouse is), and check if the mouse is off the button. If so, release capture and make the button invisible. TboXx 03-27-2004, 02:50 PM great! thanks, it finally works :) sseller 03-27-2004, 04:47 PM Alternatively you could make the button visible in the Mousemove of the label, and make it invisible again in the Mousemove of the form. That seems to work OK. Deadalus 03-27-2004, 05:17 PM The problem with that is that sooner or later the form's MouseMove won't fire and the button will stay visible. It works relatively well if the button isn't close to the form's borders or to any other controls, but even then it's possible to move the mouse so quickly over the form that the mousemove event doesn't fire. |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum