Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

tlable and the mouse

Posted on 2004-03-30
10
Medium Priority
?
221 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1040 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Integration Management Part 2

971 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