Hi
I remember certain controls in VB had this mouse_in and mouse_out function.
Pretty handy.
Is there some examples here on how we do that in FF?
The easiest way to do this across all versions of 32-bit Windows is to use a Timer to check if the mouse is over the area you desire. This technique is used in the FireFly custom controls that ship with FireFly. Check out the FireLink custom control code - that one should be easy to understand.
I was trying to make an example without a timer (more efficient because it is event driven), but WindowFromPoint doesnt seem to be working correctly.
Firefly codetips state that it takes xCoord, and yCoord, but when i add them, the compiler says a string is expected.... anyway here's the code that I believe should work:
Sub MouseInNotification(hWndControl As Dword)
Call FF_Control_SetText(hWndControl, "Mouse in!!!")
End Sub
Sub MouseOutNotification(hWndControl As Dword)
Call FF_Control_SetText(hWndControl, "Mouse Out!!!")
End Sub
'--------------------------------------------------------------------------------
Function MOUSEINOUT_LABEL1_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
Select Case wMsg
Case %WM_MOUSEMOVE
If GetCapture() <> hWndControl Then
SetCapture(hWndControl)
Call MouseInNotification(hWndControl)
Else
If WindowFromPoint(LoWrd(lparam), HiWrd(lparam)) <> hWndControl Then
ReleaseCapture()
Call MouseOutNotification(hWndControl)
End If
End If
End Select
End Function
WindowFromPoint, as its name says, expects a POINT structure. If you want to use separate coordinates, call WindowFromXY.
AFAIK it used to work with a POINT Structure. Then the API declarations changed and a X and Y coordinates were required. Well them that makes 3 diferent versions:
- Firefly says x and y coordinates are required.
- Compiler says a STRING is expected.
- Me and you say a POINT should be required.
:)
When in doubt, trust me :)
I have no doubt, it should be a POINT. :)
Paul, Perhaps this should be added to the firefly notification messages. This is working correctly:
Sub MouseInNotification(hWndControl As Dword)
Call FF_Control_SetText(hWndControl, "Mouse in!!!" & Str$(timer))
End Sub
Sub MouseOutNotification(hWndControl As Dword)
Call FF_Control_SetText(hWndControl, "Mouse Out!!!" & Str$(timer))
End Sub
'--------------------------------------------------------------------------------
Function MOUSEINOUT_LABEL1_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
Select Case wMsg
Case %WM_MOUSEMOVE
If GetCapture() <> hWndControl Then
SetCapture(hWndControl)
Call MouseInNotification(hWndControl)
Else
Local PT As POINT
GetCursorPos(PT)
If WindowFromPoint(PT) <> hWndControl Then
ReleaseCapture()
Call MouseOutNotification(hWndControl)
End If
End If
End Select
End Function
Guys, please keep in mind I am centuries behind any of you. Seriously dumb hobby programmer here...
The code of Elias looks very simple, now just help me here on firing the mouse_in event on say a PICTUREBOX.
The rest i should manage.
In that case, just replace MOUSEINOUT_LABEL1_CUSTOM with the Custom function name for the PICTURE BOX and add the apropriate action in the mouse in and mouse out event handler functions.
Here is an example with an array of controls, it is very straightforward.
Thanks for all the advice.
Was away for a while. Sorry for the late response!
Pretty Brilliant Elias!
Works like a charm!!!
Imagine any FF control with that build in.... ;)