ohh, det var javascript, tsk tsk tsk ..
Der er et eksempel på:
http://premium.microsoft.com/vbasic/browse.asp Use MouseMove Event to highlight your label.
Use Timer to check cursor position.
- if it is not inside label, un-highlight label.
Sub Timer1_Timer
ret = GetCursorPos(ptapi) ' get cursor position
lblRect = GetRect(curCtl) ' current rectangle
' now check if cursor is over current curctl
If PtInRect(lblRect, ptapi) = 0 Then
unHiLite
End If
End Sub
Public Function GetRect(liteCtl As Control) As RECT
' we cannot use API GetWindowRect directly, light controls don't have hwnd
' this works also for non-lite controls
' ScaleMode must be vbTwips!
Dim px As Integer, py As Integer
Dim ret As Long, temprect As RECT, tmppt As POINTAPI
Dim objLblParent As Object
On Error Resume Next
px = Screen.TwipsPerPixelX
py = Screen.TwipsPerPixelY
Set objLblParent = liteCtl.Container ' form or container control
tmppt.X = 0
tmppt.Y = 0
ret = ClientToScreen(objLblParent.hWnd, tmppt)
' tmppt contains screen coordinates of client point 0,0
'
' to get rectangle, use liteCtl.left, .top, .width and .height properties
temprect.Left = tmppt.X + liteCtl.Left / px
temprect.Right = temprect.Left + liteCtl.Width / px
temprect.Top = tmppt.Y + liteCtl.Top / py
temprect.Bottom = temprect.Top + liteCtl.Height / py
' return rectangle
GetRect = temprect
End Function