Has anybody used this API within FF? I want to know when the mouse pointer enters and leaves a control for some custom painting similiar to what Office does in their ribbon control.
Rick Kelly
In the custom controls I wrote I always used a Timer to track the mouse entering and leaving a control. That's because the TrackMouseEvent function was not available in pre-Win2K machines. Since FF now only supports Win2K and higher then it should be no problem to use it now.
'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_CUSTOM ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Static bMouseTracking As Long
Select Case wMsg
Case %WM_MOUSEMOVE
If bMouseTracking = %FALSE Then
Local tme As EventTrack
tme.cbSize = SizeOf(EventTrack)
tme.dwFlags = %TME_LEAVE
tme.hwndTrack = hWndControl
TrackMouseEvent tme
bMouseTracking = %TRUE
End If
Case %WM_MOUSELEAVE
Static i As Long
Incr i
FF_Control_SetText hWndForm, "Mouse leave" & Str$(i)
bMouseTracking = %FALSE
End Select
End Function
Thank you for the example and green light. I took your example and added hover time to it. I have a 48x48 bitmap with a label underneath it surrounded by a firelines box with another label control around the whole thing. Mouse gets into the outer label control and stays for the hover time and the firelines box is made visible. Mouse leaves, firelines box is hidden. If you click anywhere inside the outer label control, I catch that and off we go to another form. This way I can have a large target to click on. Small jpeg attached that shows the firelines box in it's visible state during the hover.
Rick Kelly 8)
Cool! :)
Source code sample â€" or it didn't happen! 8oÞ
Quote from: Haakon Birkeland on November 22, 2011, 01:43:51 PM
Source code sample â€" or it didn't happen! 8oÞ
The label is named PEOPLESPOT and it is set with WS_EX_TRANSPARENT. The FF lines object is named PEOPLEBOX and it is contained entirely withinn PEOPLESPOT. Inside PEOPLEBOX are the bitmap and label controls. In the forms CREATE event:
FF_Control_ShowState (HWND_MAIN_PEOPLEBOX, %SW_HIDE)
SetTransparent (HWND_MAIN_PEOPLESPOT)
Sub SetTransparent (ByVal hWndControl As Dword)
Local ff As FLY_DATA Ptr
Local hDC As Dword
ff = GetProp (hWndControl, "FLY_PTR")
@ff.hBackBrush = GetStockObject (%NULL_BRUSH)
SetProp hWndControl, "FLY_PTR", ff
hDC = GetDC(hWndControl)
SetBkMode hDC, %TRANSPARENT
ReleaseDC hWndControl, hDC
End Sub
Here's Paul's code modified for hover.
Function MAIN_PEOPLESPOT_CUSTOM ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Static bMouseTracking As Long
Select Case wMsg
Case %WM_MOUSEMOVE
If bMouseTracking = %FALSE Then
Local tme As EventTrack
tme.cbSize = SizeOf(EventTrack)
tme.dwFlags = %TME_LEAVE Or %TME_HOVER
tme.hwndTrack = hWndControl
tme.dwHoverTime = 100
TrackMouseEvent tme
bMouseTracking = %TRUE
End If
Case %WM_MOUSELEAVE
FF_Control_ShowState (HWND_MAIN_PEOPLEBOX, %SW_HIDE)
bMouseTracking = %FALSE
Case %WM_MOUSEHOVER
FF_Control_ShowState (HWND_MAIN_PEOPLEBOX, %SW_SHOW)
End Select
End Function
Enjoy!
Rick Kelly ;D