delphi - In my custom component, how can I augment the mouse-enter and -leave events? -
I am creating a custom panel component that receives TPanel .
I want to execute some code on OnMouseEnter and OnMouseLeave event for its new component, however, I do not know how to implement it Go.
I see that TPanel has published the OnMouseEnter , OnMouseLeave property.
How do I override them and some of my codes?
Example of my thoughts: The default behavior of TMyPanel that should be in the component
OnMouseEnter on the event: color: = NewColor; Lay onMouse at the event: Color: = old color;
And again, I want to be able to assign some functions to run these programs at run time. This is done in the assignment application.
.. TButton1.Click .. Start MyPanel1.OnMouseEnter: = DoSomethingMore; MyPanel1.OnMouse Le :: = DoSomethingElse; End;
Finally, when the new panel is over, it should change the color and some other actions are written in the DoSomethingMore process.
Thank you
Anohar's approach is to handle windows messages themselves: Edit: See below for the better VCL compliant version.
Type TMyPanel = class (TPanel)) personal process CMMouseEnter (var Message: TMessage); Message CM_MOUSEENTER; CMMouseLeave Process (var Message: TMessage); Message CM_MOUSELEAVE; Published end; Implementation {TMyPanel} process TMyPanel.CMMouseEnter (var Message: TMessage); Start // Whatever you want before the event, if assigned (onmointer) then OnMouseEnter (self); End; Process TMyPanel.CMMouseLeave (var Message: TMessage); Start // Whatever the event you want, if you are assigned (carry onmos) then onmos leve (self); End;
Comments
Post a Comment