|
-
May 9th, 2006, 12:26 AM
#1
Thread Starter
Member
MouseMove opposite
Is there any command works in opposite to MouseMove? I want to give a command when my cursor leave the command button.
Thanks for answering
-
May 9th, 2006, 12:51 AM
#2
Re: MouseMove opposite
You can use the MosueMove event but there are an X and Y argument that tells you the position of the mouse cursor over it. Just test for when the coordinates are 0 or just about equal the width or height of the button.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 9th, 2006, 01:01 AM
#3
Re: MouseMove opposite
You could try something like this:
VB Code:
Option Explicit
Private bMouseOverButton As Boolean
Private bIgnoreMouseMove As Boolean
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bIgnoreMouseMove Then
Exit Sub
End If
bMouseOverButton = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bIgnoreMouseMove Then
Exit Sub
End If
If bMouseOverButton Then
bIgnoreMouseMove = True
'
' do your button exit stuff
'
bMouseOverButton = False
bIgnoreMouseMove = False
End If
End Sub
The only problem with this code is if there's not much of your form showing and the user moves the mouse quickly, sometimes the MouseMove event doesn't fire.
Last edited by pnish; May 9th, 2006 at 02:52 AM.
Reason: silly typo
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
May 9th, 2006, 05:36 AM
#4
Re: MouseMove opposite
VB Code:
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case True
Case X < 0, Y < 0, X > Command1.Width, Y > Command1.Height
' Leaving
ReleaseCapture
' Do Stuff
Debug.Print "Leaving"
Case Not GetCapture() = Command1.hwnd
' Entering
SetCapture Command1.hwnd
' Do Stuff
Debug.Print "Entering"
End Select
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
|