Solved

tlable and the mouse

Posted on 2004-03-30
10
214 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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
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
 

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 54
URL for downloading Google Chrome for Win XP 2 155
Delphi: ForceDirectory plain function 7 31
how to resize animated Gif image in delphi ? 1 31
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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