Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Событие CM_MOUSELEAVE... [D6, Win2k]


Страницы:   1 2

urich ©   (2002-06-04 15:48:00) 

Есть на форме обычная метка - label1. Хочется менять цвет шрифта при наведении и при уходе мыши с компонента. Я начинающий, поэтому может мой вопрос покажится многим глупым, но может кто-нибудь снизайдет до меня и подскажет как это реализовать... Спасибо...


Игорь Шевченко   (2002-06-07 09:34:00) [1]

Vladymir (07.06.02 01:32)

На mouse...keypreview...Изврат :-)

KeyPreview property Specifies whether the form should receive keyboard events before the active control.


Vladymir   (2002-06-07 01:32:00) [2]

Игорь Шевченко © (05.06.02 11:07)

А KeyPreview поставить :)))


Игорь Шевченко   (2002-06-05 11:07:00) [3]

SPeller © (05.06.02 11:03)

А что будет, если Label на панели, а панель еще на одной панели и так далее ? :-)))
Form1.OnMouseMove не сработает :-)))


SPeller   (2002-06-05 11:03:00) [4]

Упс.. косячок....

procedure TForm1.Label1MouseMove(...);
begin
With Label1 do
if Tag=0 then begin
Tag:=1;
Font.Color:=clRed;
end;
end;

procedure TForm1.FormMouseMove(...);
begin
With Label1 do
if Tag=1 then begin
Tag:=0;
Font.Color:=clWindowText;
end;
end;


SPeller   (2002-06-05 11:01:00) [5]

Для любых Дельфи:

procedure TForm1.Label1MouseMove(...);
begin
With Label1 do
if Tag=0 then begin
Tag:=1;
Font.Color:=clRed;
end;

procedure TForm1.FormMouseMove(...);
begin
With Label1 do
if Tag=1 then begin
Tag:=0;
Font.Color:=clWindowText;
end;


Игорь Шевченко   (2002-06-05 10:21:00) [6]

Song © (05.06.02 10:08)

Это в Delphi 6


Song   (2002-06-05 10:08:00) [7]

Ну Вы ребят напридумывали... :o

procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Label1.Font.Color:=ClRed;
end;

procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
Label1.Font.Color:=ClWindowText;
end;


urich   (2002-06-05 10:04:00) [8]

Всем спасибо!!!


EternalWonderer   (2002-06-04 18:24:00) [9]

А можно проще:
меняем цвет по Label1OnMouseMove,
а обратно - по Panel1OnMouseMove,
где Label1 лежит на Panel1.


Игорь Шевченко   (2002-06-04 18:07:00) [10]

unit MouseSensitiveLabel;

interface
uses
Windows, Messages, Classes, Controls, StdCtrls;

type
TMouseSensitiveLabel = class(TLabel)
private
FOnMouseLeave: TNotifyEvent;
FOnMouseEnter: TNotifyEvent;
procedure CMMouseEnter (var Message : TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave (var Message : TMessage); message CM_MOUSELEAVE;
protected
procedure DoMouseEnter; dynamic;
procedure DoMouseLeave; dynamic;
published
property OnMouseEnter : TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave : TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;

procedure Register;

implementation

{ TMouseSensitiveLabel }

procedure TMouseSensitiveLabel.CMMouseEnter(var Message: TMessage);
begin
DoMouseEnter();
end;

procedure TMouseSensitiveLabel.CMMouseLeave(var Message: TMessage);
begin
DoMouseLeave();
end;

procedure TMouseSensitiveLabel.DoMouseEnter;
begin
if Assigned(FOnMouseEnter) then
FOnMouseEnter(Self);
end;

procedure TMouseSensitiveLabel.DoMouseLeave;
begin
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;

procedure Register;
begin
RegisterComponents ("Igor Schevchenko", [TMouseSensitiveLabel]);
end;

end.


Игорь Шевченко   (2002-06-04 17:38:00) [11]

К терапевту... :-)


urich   (2002-06-04 17:34:00) [12]

А как сделать VCL?


Игорь Шевченко   (2002-06-04 17:24:00) [13]

Да ради бога, никто не мешает. Можно даже авторских прав не указывать :-)


urich   (2002-06-04 17:18:00) [14]

А из этого можно сделать VCL?


urich   (2002-06-04 17:14:00) [15]

для Игорь Шевченко : Вау!!! СУПЕР!!! СПАСИБО ОГРОМНОЕ!!! ВСЕ ПОЛУЧИЛОСЬ !!!
СПАСИБО !!! СПАСИБО !!! СПАСИБО !!!
СПАСИБО !!! СПАСИБО !!! СПАСИБО !!!
СПАСИБО !!! СПАСИБО !!! СПАСИБО !!!


Игорь Шевченко   (2002-06-04 17:11:00) [16]

type
TfMain = class(TForm)
LabelPlace: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FLabel : TMouseSensitiveLabel;
procedure LabelMouseEnter (Sender : TObject);
procedure LabelMouseLeave (Sender : TObject);
public
{ Public declarations }
end;


urich   (2002-06-04 17:09:00) [17]

И как описывать в main "LabelMouseEnter" ?


urich   (2002-06-04 17:08:00) [18]

A kak нужно объявлять Flabel и где?


urich   (2002-06-04 16:58:00) [19]

Для ИГОРЯ: Спасибо, сейчас попробую


Игорь Шевченко   (2002-06-04 16:48:00) [20]

10 мин.

unit MouseSensitiveLabel;

interface
uses
Windows, Messages, Classes, Controls, StdCtrls;

type
TMouseSensitiveLabel = class(TLabel)
private
FOnMouseLeave: TNotifyEvent;
FOnMouseEnter: TNotifyEvent;
procedure CMMouseEnter (var Message : TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave (var Message : TMessage); message CM_MOUSELEAVE;
procedure SetOnMouseEnter(const Value: TNotifyEvent);
procedure SetOnMouseLeave(const Value: TNotifyEvent);
protected
procedure DoMouseEnter; dynamic;
procedure DoMouseLeave; dynamic;
public
property OnMouseEnter : TNotifyEvent read FOnMouseEnter write SetOnMouseEnter;
property OnMouseLeave : TNotifyEvent read FOnMouseLeave write SetOnMouseLeave;
end;

implementation

{ TMouseSensitiveLabel }

procedure TMouseSensitiveLabel.CMMouseEnter(var Message: TMessage);
begin
DoMouseEnter();
end;

procedure TMouseSensitiveLabel.CMMouseLeave(var Message: TMessage);
begin
DoMouseLeave();
end;

procedure TMouseSensitiveLabel.DoMouseEnter;
begin
if Assigned(FOnMouseEnter) then
FOnMouseEnter(Self);
end;

procedure TMouseSensitiveLabel.DoMouseLeave;
begin
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;

procedure TMouseSensitiveLabel.SetOnMouseEnter(const Value: TNotifyEvent);
begin
FOnMouseEnter := Value;
end;

procedure TMouseSensitiveLabel.SetOnMouseLeave(const Value: TNotifyEvent);
begin
FOnMouseLeave := Value;
end;

end.

main.pas

procedure TfMain.FormCreate(Sender: TObject);
begin
FLabel := TMouseSensitiveLabel.Create(Self);
with FLabel do begin
Parent := Self;
BoundsRect := LabelPlace.BoundsRect;
Caption := LabelPlace.Caption;
ParentColor := true;
ParentFont := true;
OnMouseEnter := LabelMouseEnter;
OnMouseLeave := LabelMouseLeave;
end;
end;

procedure TfMain.LabelMouseEnter(Sender: TObject);
begin
FLabel.Font.Color := clBlue;
end;

procedure TfMain.LabelMouseLeave(Sender: TObject);
begin
FLabel.Font.Color := clBlack;
end;


Страницы:   1 2

Наверх

Титульная страница Поиск, карта сайта Написать письмо