|
-
Oct 5th, 2004, 08:49 PM
#1
Thread Starter
Addicted Member
Vb's Mouseover
this have been bugging me ever since my Flash days, I havent heed it but now I need to ask, I hope you can help me guyz.
Any mouseover event in VB? how?
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
-
Oct 5th, 2004, 09:00 PM
#2
Hyperactive Member
Double click whatever control you want to add the code to (or the form). On the top of the code window, click the drop down arrow of the right combo box. Click MouseOver
Disiance
-
Oct 5th, 2004, 09:11 PM
#3
Thread Starter
Addicted Member
there is no mouveover.... Only mousemove, mousedown and mouseup.
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
-
Oct 6th, 2004, 12:24 AM
#4
MouseMove is similar to MouseOver.
-
Oct 6th, 2004, 09:01 AM
#5
Thread Starter
Addicted Member
is that all it? nothing special api-related functions or something like that??
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
-
Oct 6th, 2004, 09:51 AM
#6
You need to use TrackMouseEvent and subclass the window concerned to trap for WM_MOUSEHOVER
VB Code:
' ##ENUMERATION_DESCRIPTION Before WM_MOUSEHOVER and WM_MOUSELEAVE messages can be generated for
' ##ENUMERATION_DESCRIPTION a window, the message tracking must be enabled on that window.
Public Enum TrackMouseEvents
' ##ENUMERATION_MEMBER_DESCRIPTION TME_HOVER Request WM_MOUSEHOVER message notification
TME_HOVER = &H1
' ##ENUMERATION_MEMBER_DESCRIPTION TME_LEAVE Request WM_MOUSELEAVE message notification
TME_LEAVE = &H2
' ##ENUMERATION_MEMBER_DESCRIPTION TME_NONCLIENT Request WM_NCMOUSEHOVER and WM_NCMOUSEHOVER messages
TME_NONCLIENT = &H10
' ##ENUMERATION_MEMBER_DESCRIPTION TME_QUERY Get the mouse track status for this window
TME_QUERY = &H40000000
' ##ENUMERATION_MEMBER_DESCRIPTION TME_CANCEL Cancel mouse tracking
TME_CANCEL = &H80000000
End Enum
Private Type TRACKMOUSESTRUCT
cbSize As Long
dwFlags As Long '\\ TrackMouseEvents
hwndTrack As Long '\\ Target window
dwHoverTime As Long '\\ Mouse hover timeout in milliseconds
End Type
Private Declare Function TrackMouseEvent Lib "user32" (lpTrackMouseStruct As TRACKMOUSESTRUCT) As Long
-
Oct 6th, 2004, 08:26 PM
#7
Hyperactive Member
Well you can try something like this, I use it with a program I have and it works perfect. I use it for a startmenu in a game I made that works like windows start menus. When you mouseover them it sets to another color background. But with other pics. Heres the module I use for it:
Code:
'Programmer Info: Originally developed by Jerrame Hertz
' Modified and updated by Adam VanDerMeid
'
'Question, Comments, Suggestions? Please E-Mail [email protected]
Option Explicit
'Function found in the API Viewer
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
'Type found in the API Viewer and referenced by the GetCursorPos
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Function CheckMouseOver(FormName As Form, ControlName As Control, DefaultValue As Variant, MouseOverValue As Variant) As Variant
'return the mouse position if the screen
Dim MousePos As POINTAPI
Dim RetValue As Boolean
Dim ctrlLeft, ctrlRight, ctrlTop, ctrlBottom
Dim frmX, frmY
'Get Cursor position relevant to screen
RetValue = GetCursorPos(MousePos)
'calculate cursor position relevant to form
frmX = MousePos.X - FormName.ScaleX(FormName.Left, vbTwips, vbPixels)
frmY = MousePos.Y - FormName.ScaleY(FormName.Top, vbTwips, vbPixels)
'calculate control dimensions relevant to form
ctrlLeft = 3 + FormName.ScaleX(ControlName.Left, vbTwips, vbPixels)
ctrlRight = ctrlLeft + FormName.ScaleX(ControlName.Width, vbTwips, vbPixels)
ctrlTop = 22 + FormName.ScaleY(ControlName.Top, vbTwips, vbPixels)
ctrlBottom = ctrlTop + FormName.ScaleY(ControlName.Height, vbTwips, vbPixels)
'check cursor position against object position and return appropriate value
If (frmX > ctrlLeft) And (frmX < ctrlRight) And (frmY > ctrlTop) And (frmY < ctrlBottom) Then
CheckMouseOver = MouseOverValue
Else
CheckMouseOver = DefaultValue
End If
End Function
Then with that I used it like this:
Code:
Private Sub Timer1_Timer()
If Picture1..Visible = True Then
Picture1.Visible = CheckMouseOver(Form1, Picture3, True, False)
End If
Change the code around to best fit your needs. But it does work.
If my post was helpful please rate it 
-
Oct 8th, 2004, 12:18 AM
#8
Thread Starter
Addicted Member
thanks.. ill try that code later coz im not home.. thanks alot!
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
-
Apr 10th, 2009, 04:35 AM
#9
Member
-
Apr 10th, 2009, 07:14 AM
#10
Re: Vb's Mouseover
As long as the control exposes a hwnd property you can use Hack's code in this post.
http://www.vbforums.com/showpost.php...57&postcount=9
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
|