In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

How to trace WM_MOUSELEAVE?

Xailer professional forum in English
Responder
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

How to trace WM_MOUSELEAVE?

Mensaje por Oleg »

Hello!
Is there any way in Xailer to trace non-predefined events?
I want that my panel would trace WM_MOUSELEAVE in such code:
....
static bPanelInside:=.f.
METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
if !bPanelInside
bPanelInside:=.t.
::Panel1Enter()
TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
endif
RETURN Nil
....
I need the place where I can catch WM_MOUSELEAVE event, for example
METHOD Panel1MouseLeave( oSender) CLASS TForm1
MsgInfo('Leave')
bPanelInside:=.f.
RETURN Nil
How can I do it?
Thank you.
Oleg.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9441
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por ignacio »

Oleg,
In Xailer you can trap any Windows message just creating a method with the
same name of the message without the 'WM_' prefix. That's all.
Be aware that if you return NIL from that method is like calling
DefWindowProc(), a zero stops the message and any other value depends on the
kind of message.
If the message is already treated by Xailer you should consider to promote
the message to its ancestors with:
RETURN Super:MouseLeave( ....)
All the WM_ messages receives the following parameters: wParam, lParam, hWnd
In Xailer you can even trapWM_USER messages with the method HandleEvent(),
onces defined on any class, all the messages not processed with WM_ methods
are routed to that method.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=45064d18@news.xailer.com...]45064d18@news.xailer.com...[/email]
> Hello!
>
> Is there any way in Xailer to trace non-predefined events?
>
> I want that my panel would trace WM_MOUSELEAVE in such code:
> ...
> static bPanelInside:=.f.
>
> METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
> if !bPanelInside
> bPanelInside:=.t.
> ::Panel1Enter()
> TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
> endif
> RETURN Nil
> ...
>
> I need the place where I can catch WM_MOUSELEAVE event, for example
>
> METHOD Panel1MouseLeave( oSender) CLASS TForm1
> MsgInfo('Leave')
> bPanelInside:=.f.
> RETURN Nil
>
> How can I do it?
>
> Thank you.
> Oleg.
>
>
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
NoName
Mensajes: 531
Registrado: Vie Feb 03, 2006 7:27 pm

How to trace WM_MOUSELEAVE?

Mensaje por NoName »

Oleg,
In Xailer you can trap any Windows message just creating a method with the
same name of the message without the 'WM_' prefix. That's all.
Be aware that if you return NIL from that method is like calling
DefWindowProc(), a zero stops the message and any other value depends on the
kind of message.
If the message is already treated by Xailer you should consider to promote
the message to its ancestors with:
RETURN Super:MouseLeave( ....)
All the WM_ messages receives the following parameters: wParam, lParam, hWnd
In Xailer you can even trapWM_USER messages with the method HandleEvent(),
onces defined on any class, all the messages not processed with WM_ methods
are routed to that method.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=45064d18@news.xailer.com...]45064d18@news.xailer.com...[/email]
> Hello!
>
> Is there any way in Xailer to trace non-predefined events?
>
> I want that my panel would trace WM_MOUSELEAVE in such code:
> ...
> static bPanelInside:=.f.
>
> METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
> if !bPanelInside
> bPanelInside:=.t.
> ::Panel1Enter()
> TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
> endif
> RETURN Nil
> ...
>
> I need the place where I can catch WM_MOUSELEAVE event, for example
>
> METHOD Panel1MouseLeave( oSender) CLASS TForm1
> MsgInfo('Leave')
> bPanelInside:=.f.
> RETURN Nil
>
> How can I do it?
>
> Thank you.
> Oleg.
>
>
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9441
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por ignacio »

Oleg,
Sorry a mistake on my last message:
> In Xailer you can trap any Windows message just creating a method with the
> same name of the message without the 'WM_' prefix. That's all.
It should be:
In Xailer you can trap any Windows message just creating a method with the
same name of the message without the '_' between 'WM' and the name of the
message. For example WMKillFocus(). That's all.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Ignacio Ortiz de Zúñiga" <NoName@xailer.com> escribió en el mensaje
news:45065efe$[email=1@news.xailer.com...]1@news.xailer.com...[/email]
> Oleg,
>
> In Xailer you can trap any Windows message just creating a method with the
> same name of the message without the 'WM_' prefix. That's all.
>
> Be aware that if you return NIL from that method is like calling
> DefWindowProc(), a zero stops the message and any other value depends on
> the kind of message.
>
> If the message is already treated by Xailer you should consider to promote
> the message to its ancestors with:
>
> RETURN Super:MouseLeave( ....)
>
> All the WM_ messages receives the following parameters: wParam, lParam,
> hWnd
>
> In Xailer you can even trapWM_USER messages with the method HandleEvent(),
> onces defined on any class, all the messages not processed with WM_
> methods are routed to that method.
>
> Regards,
>
> --
> Ignacio Ortiz de Zúñiga
> http://www.xailer.com
> "Oleg" <info@cluster.samara.ru> escribió en el mensaje
> news:[email=45064d18@news.xailer.com...]45064d18@news.xailer.com...[/email]
>> Hello!
>>
>> Is there any way in Xailer to trace non-predefined events?
>>
>> I want that my panel would trace WM_MOUSELEAVE in such code:
>> ...
>> static bPanelInside:=.f.
>>
>> METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
>> if !bPanelInside
>> bPanelInside:=.t.
>> ::Panel1Enter()
>> TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
>> endif
>> RETURN Nil
>> ...
>>
>> I need the place where I can catch WM_MOUSELEAVE event, for example
>>
>> METHOD Panel1MouseLeave( oSender) CLASS TForm1
>> MsgInfo('Leave')
>> bPanelInside:=.f.
>> RETURN Nil
>>
>> How can I do it?
>>
>> Thank you.
>> Oleg.
>>
>>
>
>
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
NoName
Mensajes: 531
Registrado: Vie Feb 03, 2006 7:27 pm

How to trace WM_MOUSELEAVE?

Mensaje por NoName »

Oleg,
Sorry a mistake on my last message:
> In Xailer you can trap any Windows message just creating a method with the
> same name of the message without the 'WM_' prefix. That's all.
It should be:
In Xailer you can trap any Windows message just creating a method with the
same name of the message without the '_' between 'WM' and the name of the
message. For example WMKillFocus(). That's all.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Ignacio Ortiz de Zúñiga" <NoName@xailer.com> escribió en el mensaje
news:45065efe$[email=1@news.xailer.com...]1@news.xailer.com...[/email]
> Oleg,
>
> In Xailer you can trap any Windows message just creating a method with the
> same name of the message without the 'WM_' prefix. That's all.
>
> Be aware that if you return NIL from that method is like calling
> DefWindowProc(), a zero stops the message and any other value depends on
> the kind of message.
>
> If the message is already treated by Xailer you should consider to promote
> the message to its ancestors with:
>
> RETURN Super:MouseLeave( ....)
>
> All the WM_ messages receives the following parameters: wParam, lParam,
> hWnd
>
> In Xailer you can even trapWM_USER messages with the method HandleEvent(),
> onces defined on any class, all the messages not processed with WM_
> methods are routed to that method.
>
> Regards,
>
> --
> Ignacio Ortiz de Zúñiga
> http://www.xailer.com
> "Oleg" <info@cluster.samara.ru> escribió en el mensaje
> news:[email=45064d18@news.xailer.com...]45064d18@news.xailer.com...[/email]
>> Hello!
>>
>> Is there any way in Xailer to trace non-predefined events?
>>
>> I want that my panel would trace WM_MOUSELEAVE in such code:
>> ...
>> static bPanelInside:=.f.
>>
>> METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
>> if !bPanelInside
>> bPanelInside:=.t.
>> ::Panel1Enter()
>> TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
>> endif
>> RETURN Nil
>> ...
>>
>> I need the place where I can catch WM_MOUSELEAVE event, for example
>>
>> METHOD Panel1MouseLeave( oSender) CLASS TForm1
>> MsgInfo('Leave')
>> bPanelInside:=.f.
>> RETURN Nil
>>
>> How can I do it?
>>
>> Thank you.
>> Oleg.
>>
>>
>
>
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por jfgimenez »

Oleg,
> Maybe all these ways work, but not in my case.
> I think that it is so because WM_MOUSELEAVE message is routed to Panel
> control, but I catch it in Form method.
> I can create MouseLeave method for a form only, but I cannot create it for
> a
> Panel control.
You should create a TPanel class inherited from XPanel one:
CLASS TPanel FROM XPanel
EVENT OnMouseLeave( oSender )
METHOD WMMouseMove( nWParam, nLParam )
METHOD WMMouseLeave( nWParam, nLParam )
ENDCLASS
METHOD WMMouseMove( nWParam, nLParam ) CLASS TPanel
// Avoid capturing the mouse if the event is not assigned
IF XA_EventAssigned( "OnMouseLeave" )
TrackMouseEvent( ::Handle, TME_LEAVE, HOVER_DEFAULT )
ENDIF
RETURN Super:WMMouseMove( nWParam, nLParam )
METHOD WMMouseLeave( nWParam, nLParam )
::OnMouseLeave()
RETURN 0
Later, you may assign OnMouseLeave to any panel, and do whatever you want.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por jfgimenez »

Oleg,
> Maybe all these ways work, but not in my case.
> I think that it is so because WM_MOUSELEAVE message is routed to Panel
> control, but I catch it in Form method.
> I can create MouseLeave method for a form only, but I cannot create it for
> a
> Panel control.
You should create a TPanel class inherited from XPanel one:
CLASS TPanel FROM XPanel
EVENT OnMouseLeave( oSender )
METHOD WMMouseMove( nWParam, nLParam )
METHOD WMMouseLeave( nWParam, nLParam )
ENDCLASS
METHOD WMMouseMove( nWParam, nLParam ) CLASS TPanel
// Avoid capturing the mouse if the event is not assigned
IF XA_EventAssigned( "OnMouseLeave" )
TrackMouseEvent( ::Handle, TME_LEAVE, HOVER_DEFAULT )
ENDIF
RETURN Super:WMMouseMove( nWParam, nLParam )
METHOD WMMouseLeave( nWParam, nLParam )
::OnMouseLeave()
RETURN 0
Later, you may assign OnMouseLeave to any panel, and do whatever you want.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por jfgimenez »

Oleg,
> It would be great if you could provide TStdControl with predefined events
> OnMouseEnter and OnMouseLeave in the next revisions.
> I think these events are quite useful.
There are several controls that capture the mouse under certain conditions,
so it's not a good idea to do it genericaly for TStdControl, as it could
cause other problems and undesired effects.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por jfgimenez »

Oleg,
> It would be great if you could provide TStdControl with predefined events
> OnMouseEnter and OnMouseLeave in the next revisions.
> I think these events are quite useful.
There are several controls that capture the mouse under certain conditions,
so it's not a good idea to do it genericaly for TStdControl, as it could
cause other problems and undesired effects.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9441
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por ignacio »

Oleg,
I attach with this message a small sample to track Mouseleave events on
Panels.
> It would be great if you could provide TStdControl with predefined events
> OnMouseEnter and OnMouseLeave in the next revisions.
> I think these events are quite useful.
We did not do it since we believe it will have a important impact in
performance.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=45068d75@news.xailer.com...]45068d75@news.xailer.com...[/email]
> Ignacio,
>
>> In Xailer you can trap any Windows message just creating a method with
>> the
>> same name of the message without the 'WM_' prefix. That's all.
>>
>> Be aware that if you return NIL from that method is like calling
>> DefWindowProc(), a zero stops the message and any other value depends on
> the
>> kind of message.
>>
>> If the message is already treated by Xailer you should consider to
>> promote
>> the message to its ancestors with:
>>
>> RETURN Super:MouseLeave( ....)
>>
>> All the WM_ messages receives the following parameters: wParam, lParam,
> hWnd
>>
>> In Xailer you can even trapWM_USER messages with the method
>> HandleEvent(),
>> onces defined on any class, all the messages not processed with WM_
> methods
>> are routed to that method.
>
> Thank you for information on Xailer's internals.
>
> Maybe all these ways work, but not in my case.
> I think that it is so because WM_MOUSELEAVE message is routed to Panel
> control, but I catch it in Form method.
> I can create MouseLeave method for a form only, but I cannot create it for
> a
> Panel control.
>
> I was able to catch WM_MOUSELEAVE message with such code (fragment).
> But this code is unusable if I need to do the same with several controls.
>
> METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
> if empty(oSender:Cargo)
> oSender:Cargo:=.t.
> ::Panel1Enter()
> INITPANELPROC(oSender:Handle) // Reassign Panel WndProc
> TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
> endif
> RETURN Nil
>
> METHOD MouseLeave( oSender ) CLASS TForm1
> if !oSender:lFocused
> ::Panel1Exit()
> endif
> oSender:Cargo:=NIL
> RETURN 0
>
> func MouseLeaveProc( oCtl )
> oCtl:oForm:MouseLeave(oCtl)
> RETURN Nil
>
> #pragma BEGINDUMP
>
> static WNDPROC wpOrigPanelProc = 0;
>
> LRESULT APIENTRY PanelCtrlProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
> lParam)
> {
> PHB_DYNS pSymTest;
>
> if(msg == WM_MOUSELEAVE){
> if( ( pSymTest = hb_dynsymFind( "MOUSELEAVEPROC" ) ) != NULL )
> {
> hb_vmPushSymbol( pSymTest->pSymbol );
> hb_vmPushNil();
> hb_vmPush(GetControlFromHandle(hWnd));
> hb_vmDo( 1 );
>
> return 0;
> }
> else
> return 0;
> }
> else
> return CallWindowProc(wpOrigPanelProc, hWnd, msg, wParam, lParam );
> }
>
> XA_FUNC( INITPANELPROC )
> {
> WNDPROC wpPanelProc;
>
> wpPanelProc = (WNDPROC) SetWindowLong( (HWND) hb_parnl(1),
> GWL_WNDPROC, (LONG) PanelCtrlProc);
> if(!wpOrigPanelProc){
> wpOrigPanelProc = wpPanelProc;
> }
> }
>
> #pragma ENDDUMP
>
>
> It would be great if you could provide TStdControl with predefined events
> OnMouseEnter and OnMouseLeave in the next revisions.
> I think these events are quite useful.
>
> Regards,
> Oleg
>
>
>
>


Attached files test.zip (2.1 KB)Â
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
NoName
Mensajes: 531
Registrado: Vie Feb 03, 2006 7:27 pm

How to trace WM_MOUSELEAVE?

Mensaje por NoName »

Oleg,
I attach with this message a small sample to track Mouseleave events on
Panels.
> It would be great if you could provide TStdControl with predefined events
> OnMouseEnter and OnMouseLeave in the next revisions.
> I think these events are quite useful.
We did not do it since we believe it will have a important impact in
performance.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Oleg" <info@cluster.samara.ru> escribió en el mensaje
news:[email=45068d75@news.xailer.com...]45068d75@news.xailer.com...[/email]
> Ignacio,
>
>> In Xailer you can trap any Windows message just creating a method with
>> the
>> same name of the message without the 'WM_' prefix. That's all.
>>
>> Be aware that if you return NIL from that method is like calling
>> DefWindowProc(), a zero stops the message and any other value depends on
> the
>> kind of message.
>>
>> If the message is already treated by Xailer you should consider to
>> promote
>> the message to its ancestors with:
>>
>> RETURN Super:MouseLeave( ....)
>>
>> All the WM_ messages receives the following parameters: wParam, lParam,
> hWnd
>>
>> In Xailer you can even trapWM_USER messages with the method
>> HandleEvent(),
>> onces defined on any class, all the messages not processed with WM_
> methods
>> are routed to that method.
>
> Thank you for information on Xailer's internals.
>
> Maybe all these ways work, but not in my case.
> I think that it is so because WM_MOUSELEAVE message is routed to Panel
> control, but I catch it in Form method.
> I can create MouseLeave method for a form only, but I cannot create it for
> a
> Panel control.
>
> I was able to catch WM_MOUSELEAVE message with such code (fragment).
> But this code is unusable if I need to do the same with several controls.
>
> METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
> if empty(oSender:Cargo)
> oSender:Cargo:=.t.
> ::Panel1Enter()
> INITPANELPROC(oSender:Handle) // Reassign Panel WndProc
> TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
> endif
> RETURN Nil
>
> METHOD MouseLeave( oSender ) CLASS TForm1
> if !oSender:lFocused
> ::Panel1Exit()
> endif
> oSender:Cargo:=NIL
> RETURN 0
>
> func MouseLeaveProc( oCtl )
> oCtl:oForm:MouseLeave(oCtl)
> RETURN Nil
>
> #pragma BEGINDUMP
>
> static WNDPROC wpOrigPanelProc = 0;
>
> LRESULT APIENTRY PanelCtrlProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
> lParam)
> {
> PHB_DYNS pSymTest;
>
> if(msg == WM_MOUSELEAVE){
> if( ( pSymTest = hb_dynsymFind( "MOUSELEAVEPROC" ) ) != NULL )
> {
> hb_vmPushSymbol( pSymTest->pSymbol );
> hb_vmPushNil();
> hb_vmPush(GetControlFromHandle(hWnd));
> hb_vmDo( 1 );
>
> return 0;
> }
> else
> return 0;
> }
> else
> return CallWindowProc(wpOrigPanelProc, hWnd, msg, wParam, lParam );
> }
>
> XA_FUNC( INITPANELPROC )
> {
> WNDPROC wpPanelProc;
>
> wpPanelProc = (WNDPROC) SetWindowLong( (HWND) hb_parnl(1),
> GWL_WNDPROC, (LONG) PanelCtrlProc);
> if(!wpOrigPanelProc){
> wpOrigPanelProc = wpPanelProc;
> }
> }
>
> #pragma ENDDUMP
>
>
> It would be great if you could provide TStdControl with predefined events
> OnMouseEnter and OnMouseLeave in the next revisions.
> I think these events are quite useful.
>
> Regards,
> Oleg
>
>
>
>


Attached files test.zip (2.1 KB)Â
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

How to trace WM_MOUSELEAVE?

Mensaje por Oleg »

Ignacio,
> In Xailer you can trap any Windows message just creating a method with the
> same name of the message without the 'WM_' prefix. That's all.
>
> Be aware that if you return NIL from that method is like calling
> DefWindowProc(), a zero stops the message and any other value depends on
the
> kind of message.
>
> If the message is already treated by Xailer you should consider to promote
> the message to its ancestors with:
>
> RETURN Super:MouseLeave( ....)
>
> All the WM_ messages receives the following parameters: wParam, lParam,
hWnd
>
> In Xailer you can even trapWM_USER messages with the method HandleEvent(),
> onces defined on any class, all the messages not processed with WM_
methods
> are routed to that method.
Thank you for information on Xailer's internals.
Maybe all these ways work, but not in my case.
I think that it is so because WM_MOUSELEAVE message is routed to Panel
control, but I catch it in Form method.
I can create MouseLeave method for a form only, but I cannot create it for a
Panel control.
I was able to catch WM_MOUSELEAVE message with such code (fragment).
But this code is unusable if I need to do the same with several controls.
METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
if empty(oSender:Cargo)
oSender:Cargo:=.t.
::Panel1Enter()
INITPANELPROC(oSender:Handle) // Reassign Panel WndProc
TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
endif
RETURN Nil
METHOD MouseLeave( oSender ) CLASS TForm1
if !oSender:lFocused
::Panel1Exit()
endif
oSender:Cargo:=NIL
RETURN 0
func MouseLeaveProc( oCtl )
oCtl:oForm:MouseLeave(oCtl)
RETURN Nil
#pragma BEGINDUMP
static WNDPROC wpOrigPanelProc = 0;
LRESULT APIENTRY PanelCtrlProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
lParam)
{
PHB_DYNS pSymTest;
if(msg == WM_MOUSELEAVE){
if( ( pSymTest = hb_dynsymFind( "MOUSELEAVEPROC" ) ) != NULL )
{
hb_vmPushSymbol( pSymTest->pSymbol );
hb_vmPushNil();
hb_vmPush(GetControlFromHandle(hWnd));
hb_vmDo( 1 );
return 0;
}
else
return 0;
}
else
return CallWindowProc(wpOrigPanelProc, hWnd, msg, wParam, lParam );
}
XA_FUNC( INITPANELPROC )
{
WNDPROC wpPanelProc;
wpPanelProc = (WNDPROC) SetWindowLong( (HWND) hb_parnl(1),
GWL_WNDPROC, (LONG) PanelCtrlProc);
if(!wpOrigPanelProc){
wpOrigPanelProc = wpPanelProc;
}
}
#pragma ENDDUMP
It would be great if you could provide TStdControl with predefined events
OnMouseEnter and OnMouseLeave in the next revisions.
I think these events are quite useful.
Regards,
Oleg
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

How to trace WM_MOUSELEAVE?

Mensaje por Oleg »

Ignacio,
> In Xailer you can trap any Windows message just creating a method with the
> same name of the message without the 'WM_' prefix. That's all.
>
> Be aware that if you return NIL from that method is like calling
> DefWindowProc(), a zero stops the message and any other value depends on
the
> kind of message.
>
> If the message is already treated by Xailer you should consider to promote
> the message to its ancestors with:
>
> RETURN Super:MouseLeave( ....)
>
> All the WM_ messages receives the following parameters: wParam, lParam,
hWnd
>
> In Xailer you can even trapWM_USER messages with the method HandleEvent(),
> onces defined on any class, all the messages not processed with WM_
methods
> are routed to that method.
Thank you for information on Xailer's internals.
Maybe all these ways work, but not in my case.
I think that it is so because WM_MOUSELEAVE message is routed to Panel
control, but I catch it in Form method.
I can create MouseLeave method for a form only, but I cannot create it for a
Panel control.
I was able to catch WM_MOUSELEAVE message with such code (fragment).
But this code is unusable if I need to do the same with several controls.
METHOD Panel1MouseMove( oSender, nKeyFlags, nPosX, nPosY ) CLASS TForm1
if empty(oSender:Cargo)
oSender:Cargo:=.t.
::Panel1Enter()
INITPANELPROC(oSender:Handle) // Reassign Panel WndProc
TrackMouseEvent(oSender:Handle, TME_LEAVE, HOVER_DEFAULT)
endif
RETURN Nil
METHOD MouseLeave( oSender ) CLASS TForm1
if !oSender:lFocused
::Panel1Exit()
endif
oSender:Cargo:=NIL
RETURN 0
func MouseLeaveProc( oCtl )
oCtl:oForm:MouseLeave(oCtl)
RETURN Nil
#pragma BEGINDUMP
static WNDPROC wpOrigPanelProc = 0;
LRESULT APIENTRY PanelCtrlProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
lParam)
{
PHB_DYNS pSymTest;
if(msg == WM_MOUSELEAVE){
if( ( pSymTest = hb_dynsymFind( "MOUSELEAVEPROC" ) ) != NULL )
{
hb_vmPushSymbol( pSymTest->pSymbol );
hb_vmPushNil();
hb_vmPush(GetControlFromHandle(hWnd));
hb_vmDo( 1 );
return 0;
}
else
return 0;
}
else
return CallWindowProc(wpOrigPanelProc, hWnd, msg, wParam, lParam );
}
XA_FUNC( INITPANELPROC )
{
WNDPROC wpPanelProc;
wpPanelProc = (WNDPROC) SetWindowLong( (HWND) hb_parnl(1),
GWL_WNDPROC, (LONG) PanelCtrlProc);
if(!wpOrigPanelProc){
wpOrigPanelProc = wpPanelProc;
}
}
#pragma ENDDUMP
It would be great if you could provide TStdControl with predefined events
OnMouseEnter and OnMouseLeave in the next revisions.
I think these events are quite useful.
Regards,
Oleg
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por jfgimenez »

Oleg,
> Thank you. It is just what I need. The small correction was to make
> XA_EventAssigned on PRG level:
>
> XA_FUNC( XA_EVENTASSIGNED )
> {
> hb_retl(XA_EventAssigned( hb_param(1, HB_IT_OBJECT), hb_parcx(2) ));
> }
Sorry, my fault. I wrote the sample 'on the fly' :-(
There is a corresponding method in TCompoent: EventAssigned( <cMethod> ).
So, the valid code is:
METHOD WMMouseMove( nWParam, nLParam ) CLASS TPanel
// Avoid capturing the mouse if the event is not assigned
IF ::EventAssigned( "OnMouseLeave" )
TrackMouseEvent( ::Handle, TME_LEAVE, HOVER_DEFAULT )
ENDIF
RETURN Super:WMMouseMove( nWParam, nLParam )
--
Regards,
Jose F. Gimenez
http://www.xailer.com
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

How to trace WM_MOUSELEAVE?

Mensaje por jfgimenez »

Oleg,
> Thank you. It is just what I need. The small correction was to make
> XA_EventAssigned on PRG level:
>
> XA_FUNC( XA_EVENTASSIGNED )
> {
> hb_retl(XA_EventAssigned( hb_param(1, HB_IT_OBJECT), hb_parcx(2) ));
> }
Sorry, my fault. I wrote the sample 'on the fly' :-(
There is a corresponding method in TCompoent: EventAssigned( <cMethod> ).
So, the valid code is:
METHOD WMMouseMove( nWParam, nLParam ) CLASS TPanel
// Avoid capturing the mouse if the event is not assigned
IF ::EventAssigned( "OnMouseLeave" )
TrackMouseEvent( ::Handle, TME_LEAVE, HOVER_DEFAULT )
ENDIF
RETURN Super:WMMouseMove( nWParam, nLParam )
--
Regards,
Jose F. Gimenez
http://www.xailer.com
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

How to trace WM_MOUSELEAVE?

Mensaje por Oleg »

Jose, Ignacio!
> You should create a TPanel class inherited from XPanel one:
>
> CLASS TPanel FROM XPanel
> EVENT OnMouseLeave( oSender )
> METHOD WMMouseMove( nWParam, nLParam )
> METHOD WMMouseLeave( nWParam, nLParam )
> ENDCLASS
>
> METHOD WMMouseMove( nWParam, nLParam ) CLASS TPanel
> // Avoid capturing the mouse if the event is not assigned
> IF XA_EventAssigned( "OnMouseLeave" )
> TrackMouseEvent( ::Handle, TME_LEAVE, HOVER_DEFAULT )
> ENDIF
> RETURN Super:WMMouseMove( nWParam, nLParam )
>
> METHOD WMMouseLeave( nWParam, nLParam )
> ::OnMouseLeave()
> RETURN 0
>
>
> Later, you may assign OnMouseLeave to any panel, and do whatever you want.
Thank you. It is just what I need. The small correction was to make
XA_EventAssigned on PRG level:
XA_FUNC( XA_EVENTASSIGNED )
{
hb_retl(XA_EventAssigned( hb_param(1, HB_IT_OBJECT), hb_parcx(2) ));
}
Regards,
Oleg
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

How to trace WM_MOUSELEAVE?

Mensaje por Oleg »

Jose, Ignacio!
> You should create a TPanel class inherited from XPanel one:
>
> CLASS TPanel FROM XPanel
> EVENT OnMouseLeave( oSender )
> METHOD WMMouseMove( nWParam, nLParam )
> METHOD WMMouseLeave( nWParam, nLParam )
> ENDCLASS
>
> METHOD WMMouseMove( nWParam, nLParam ) CLASS TPanel
> // Avoid capturing the mouse if the event is not assigned
> IF XA_EventAssigned( "OnMouseLeave" )
> TrackMouseEvent( ::Handle, TME_LEAVE, HOVER_DEFAULT )
> ENDIF
> RETURN Super:WMMouseMove( nWParam, nLParam )
>
> METHOD WMMouseLeave( nWParam, nLParam )
> ::OnMouseLeave()
> RETURN 0
>
>
> Later, you may assign OnMouseLeave to any panel, and do whatever you want.
Thank you. It is just what I need. The small correction was to make
XA_EventAssigned on PRG level:
XA_FUNC( XA_EVENTASSIGNED )
{
hb_retl(XA_EventAssigned( hb_param(1, HB_IT_OBJECT), hb_parcx(2) ));
}
Regards,
Oleg
Responder