Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 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
1-47572
B0ard
2002-06-27 21:29
2002.07.15
Конкретный вопрос


6-47659
программист
2002-05-07 18:29
2002.07.15
Помогите пожалуйста...


3-47139
jaric
2002-06-18 16:14
2002.07.15
Как испоьз в одном запросе 2 dbf-ки из разных каталогов


1-47386
First_May
2002-07-02 10:08
2002.07.15
Форма + DLL


8-47623
Ruslan.
2002-03-06 19:57
2002.07.15
DXWaveList





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский