Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

tlable and the mouse

Posted on 2004-03-30
10
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

660 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