Форум: "Основная";
Текущий архив: 2002.07.15;
Скачать: [xml.tar.bz2];
Внизнаследник от TPanel с onmouseleave Найти похожие ветки
← →
spacerex (2002-06-27 17:15) [0]Как создать Свой наследник от TPanel с onmouseleave
← →
Игорь Шевченко (2002-06-27 17:17) [1]Сам наследник:
unit MouseSensitivePanel;
interface
uses
ExtCtrls, Controls, Classes, Messages;
type
TMouseSensitivePanel = class(TPanel)
private
FOnMouseLeave: TNotifyEvent;
FOnMouseEnter: TNotifyEvent;
procedure CMMouseEnter (var Message : TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave (var Message : TMessage); message CM_MOUSELEAVE;
procedure DoMouseEnter; dynamic;
procedure DoMouseLeave; dynamic;
published
property OnMouseEnter : TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave : TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;
implementation
{ TMouseSensitivePanel }
procedure TMouseSensitivePanel.CMMouseEnter(var Message: TMessage);
begin
inherited;
DoMouseEnter();
end;
procedure TMouseSensitivePanel.CMMouseLeave(var Message: TMessage);
begin
inherited;
DoMouseLeave();
end;
procedure TMouseSensitivePanel.DoMouseEnter;
begin
if Assigned(FOnMouseEnter) then
FOnMouseEnter(Self);
end;
procedure TMouseSensitivePanel.DoMouseLeave;
begin
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;
end.
Пример использования:
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
MouseSensitivePanel, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
FPanel : TMouseSensitivePanel;
procedure PanelMouseEnter (Sender : TObject);
procedure PanelMouseLeave (Sender : TObject);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.PanelMouseEnter(Sender: TObject);
begin
(Sender AS TPanel).Color := clRed;
end;
procedure TForm1.PanelMouseLeave(Sender: TObject);
begin
(Sender AS TPanel).Color := clBtnFace;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FPanel := TMouseSensitivePanel.Create(Self);
with FPanel do begin
Parent := Self;
BoundsRect := Panel1.BoundsRect;
OnMouseEnter := PanelMouseEnter;
OnMouseLeave := PanelMouseLeave;
end;
end;
end.
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.07.15;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.016 c