Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.11.03;
Скачать: CL | DM;

Вниз

Создание компонента   Найти похожие ветки 

 
Инна   (2003-10-22 12:41) [0]

Я пытаюсь создать (впервые:) свой компонент - надпись, меняющую цвет при наведении мыши. Но, что-то не получается:(
Код (место и вид ошибки-комментарий)

uses
Windows, Messages, SysUtils, Classes,Graphics, QControls, QStdCtrls;

type
TInetLabel = class(TLabel)
private
FDownColor,FC:integer;

{ Private declarations }
protected
procedure MouseEnter; override;
//Declaration of "<element>" differs from previous declaration
procedure MouseLeave; override;
{ Protected declarations }
public
{ Public declarations }
published
DC:TColor read FDownColor write FDownColor;
constructor Create(aowner:Tcomponent);override;
{ Published declarations }
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents("Samples", [TInetLabel]);
end;

constructor TInetLabel.Create(Aowner:Tcomponent);
begin
inherited Create(Aowner);
end;

procedure TInetLabel.MouseEnter;
begin
inherited MouseEnter;
FC:=Font.Color;
Font.Color:=DC;
end;

procedure TInetLabel.MouseLeave;
begin
inherited MouseLeave;
Font.Color:=FC;
end;

Помогите!!! Заранее спасибо:)


 
Rouse_ ©   (2003-10-22 12:47) [1]

> QControls, QStdCtrls;
Замени на обычные.

procedure OnMouseEnter; override;
procedure OnMouseLeave; override;


> DC:TColor read FDownColor
property DC: TColor read ...

Желаю успехов


 
Skier ©   (2003-10-22 12:49) [2]

procedure MouseEnter (AControl: TControl); override;
procedure MouseLeave (AControl: TControl); override;


 
Reindeer Moss Eater ©   (2003-10-22 12:50) [3]

procedure MouseEnter; override;

Нельзя переопределить того, чего нет.


 
Семен Сорокин ©   (2003-10-22 12:50) [4]

uses
Windows, Messages, SysUtils, Classes,Graphics, QControls, QStdCtrls {Зачем??, может StdCtrls};

type
TInetLabel = class(TLabel)
private
FDownColor,FC:integer;

{ Private declarations }
protected
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
{ Protected declarations }
public
{ Public declarations }
published
DC:TColor read FDownColor write FDownColor;
constructor Create(aowner:Tcomponent);override;
{ Published declarations }
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents("Samples", [TInetLabel]);
end;

constructor TInetLabel.Create(Aowner:Tcomponent);
begin
inherited Create(Aowner);
end;

procedure TInetLabel.CMMouseEnter(var Message: TMessage);
begin
inherited MouseEnter;
FC:=Font.Color;
Font.Color:=DC;
Invalidate;
end;

procedure TInetLabel.CMMouseLeave(var Message: TMessage);
begin
inherited;
Font.Color:=FC;
Invalidate;
end;


 
Skier ©   (2003-10-22 12:54) [5]

Мда... [2] отменяется ! см. Семен Сорокин © (22.10.03 12:50)[4] + property DC: TColor read ...


 
Юрий Федоров ©   (2003-10-22 12:58) [6]

Не называй такое свойство DC :))
Потому что обычно так называют Device Context


 
Skier ©   (2003-10-22 12:59) [7]

[4] + Хорошо бы добавить дин. методы диспецеризации событий
CM_MOUSEENTER и CM_MOUSELEAVE


 
Rouse_ ©   (2003-10-22 13:01) [8]

Мдяяя, с OnMouseEnter я конечно ляпнул ;)


 
Инна   (2003-10-23 10:02) [9]

Спасибо всем! Вчера Инет внезапно закончился, сегодня попробую ваши варианты:)


 
MBo ©   (2003-10-23 10:15) [10]

еще может помочь
http://www.swissdelphicenter.ch/en/showcode.php?id=1068



Страницы: 1 вся ветка

Текущий архив: 2003.11.03;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.016 c
3-8279
Art
2003-10-13 23:55
2003.11.03
Ошибка при переносе проги на другой ПК (InterBase)


1-8422
Oleg Barsky
2003-10-22 12:31
2003.11.03
Как узнать существует ли дирректория?


1-8528
TRyaSS
2003-10-23 14:59
2003.11.03
Сообщение об открытии какой-либо программы


1-8523
Igit
2003-10-23 17:04
2003.11.03
LPVOID в Дельфи


1-8445
Mistic
2003-10-21 20:59
2003.11.03
Командноая строка в своей проге?