Solved

tlable and the mouse

Posted on 2004-03-30
10
212 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

19 Experts available now in Live!

Get 1:1 Help Now