Solved

tlable and the mouse

Posted on 2004-03-30
10
213 Views
Last Modified: 2010-04-05
I want to change my lable  color if the mouse....

1-over it   >>>>>red color.
2-click it   >>>>>green color.
3-leave it  >>>>white color.
0
Comment
Question by:sal1150
10 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10719317
procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
  Label1.Color := clRed;
end;

procedure TForm1.Label1MouseEnter(Sender: TObject);
begin
  Label1.Color := clGreen;
end;

procedure TForm1.Label1Click(Sender: TObject);
begin
  Label1.Color := clYellow;
end;

0
 
LVL 17

Expert Comment

by:mokule
ID: 10719328

Instead of
procedure TForm1.Label1Click(Sender: TObject);
better may be

procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Label1.Color := clWhite;
end;

0
 
LVL 2

Expert Comment

by:Moroni24
ID: 10719340
Homework????




unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    procedure Label1MouseEnter(Sender: TObject);
    procedure Label1MouseLeave(Sender: TObject);
    procedure Label1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Label1MouseEnter(Sender: TObject);
begin
  label1.font.Color := clRed;
end;

procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
  label1.font.Color := clWhite;
end;

procedure TForm1.Label1Click(Sender: TObject);
begin
  label1.font.Color := clGreen;
end;

end.
0
 
LVL 17

Expert Comment

by:mokule
ID: 10719348
Or better may be
procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
  if Sender is TLabel then
     (Sender as TLabel).Color := clRed;
end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10719365
Do You mean Label color or Label.Font Color?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:sal1150
ID: 10719408
sorry mokule
I mean Label  Label.Font Color .
0
 

Author Comment

by:sal1150
ID: 10719435
SORRY mokule
I mean   Label.Font Color .
0
 
LVL 17

Expert Comment

by:mokule
ID: 10719452
Never mind ;-)
0
 

Accepted Solution

by:
d1kGroup earned 260 total points
ID: 10721709
make a form...put a label an it and add this events to it!

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    procedure Label1MouseEnter(Sender: TObject);
    procedure Label1MouseLeave(Sender: TObject);
    procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Label1MouseEnter(Sender: TObject);
begin
  TLabel(Sender).Font.Color := clGreen;
end;

procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
  TLabel(Sender).Font.Color := clRed;
end;

procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TLabel(Sender).Font.Color := clYellow;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Label1.Font.Color := clRed;
end;

end.
0
 
LVL 17

Expert Comment

by:mokule
ID: 10721759
Hi d1kGroup,
What new here?
Marek
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Thread safe  opinion 7 126
How to use Hashing sha1 in Delphi 2010 4 199
FMX StringGrid1->Canvas->FillRect Problem 3 127
Correct Component for Shopping Cart. 2 95
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now