Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2003.11.03;
Скачать: [xml.tar.bz2];

Вниз

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

 
Инна   (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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.009 c
1-8462
Николашка
2003-10-22 14:45
2003.11.03
Rave


14-8583
sniknik
2003-10-15 13:25
2003.11.03
Уфа это где, что? ;о))


3-8265
Relaxxx
2003-10-13 18:12
2003.11.03
быстрее ли SQL чем стандартный перебор всей таблицы


14-8593
Izyum
2003-10-15 13:34
2003.11.03
Как становятся Мастерами?


1-8428
sazon
2003-10-21 18:20
2003.11.03
TMenu





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский