MouseEnter und MouseLeave für TScrollBox
Wie kann ich ein MouseEnter oder Leave für eine ScrollBox umsetzen? Egal ob ich die Komponente ableite, oder kann man das mit Handles lösen?
Danke! |
Re: MouseEnter und MouseLeave für TScrollBox
Hi,
Leide die TScrollBox ab und füge ihr Handler für CM_MOUSEENTER und CM_MOUSELEAVE hinzu. Das sieht dann etwa so aus (ungetestet):
Delphi-Quellcode:
unit ScrollBox;
interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls; type TScrollBoxEx = class (TScrollBox) private { Private declarations } FOnMouseLeave: TNotifyEvent; FOnMouseEnter: TNotifyEvent; procedure CMMouseEnter(var msg: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var msg: TMessage); message CM_MOUSELEAVE; protected { Protected declarations } procedure DoMouseEnter; dynamic; procedure DoMouseLeave; dynamic; public { Public declarations } published { Published declarations } property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter; property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave; end; procedure Register; implementation procedure Register; begin RegisterComponents('Additional', [TScrollBoxEx]); end; { TScrollBoxEx } procedure TScrollBoxEx.CMMouseEnter(var msg: TMessage); begin DoMouseEnter; end; procedure TScrollBoxEx.CMMouseLeave(var msg: TMessage); begin DoMouseLeave; end; procedure TScrollBoxEx.DoMouseEnter; begin if Assigned(FOnMouseEnter) then FOnMouseEnter(Self); end; procedure TScrollBoxEx.DoMouseLeave; begin if Assigned(FOnMouseLeave) then FOnMouseLeave(Self); end; end. |
Re: MouseEnter und MouseLeave für TScrollBox
:hello: Danke! :hello:
Nichtnur, dass ich jetzt mein Programm vervollständigen kann, ich habe jetzt meine erste selbsterstellte Komponente! :party: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:32 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz