Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Standard Controls/TLabel    [ Add a report in this area ]  
Report #:  102788   Status: Reported
Wish TLabel could glow
Project:  Delphi Build #:  16.0.4358.45540
Version:    16.3 Submitted By:   Len Yates
Report Type:  Issue Date Reported:  1/22/2012 2:47:57 PM
Severity:    Extreme corner case Last Updated: 1/23/2012 5:30:40 PM
Platform:    All platforms Internal Tracking #:  
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
It would be nice if a TLabel could be set to color up (glow) like a TButton when the cursor is hovering over it when I have assigned an action to the TLabel.OnClick handler.
Steps to Reproduce:
None
Workarounds
None
Attachment
None
Comments

Tomohiro Takahashi at 1/22/2012 6:42:51 PM -
> ... TLabel  ...
Is it VCL's TLabel or FireMonkey's one?

> ... a TButton when the cursor is hovering over it ...
As you know, TButton is a wrapper of button control of OS. and, it is rendered according to current Runtime Theme of your OS.

Len Yates at 1/23/2012 12:15:56 PM -
I am referring to a VCL TLabel.

Jan Zdenek at 2/23/2012 12:59:33 PM -
This is probably not exactly what you're asking for, but I believe it could substitute a little:

procedure GlowMe(ALabel : TLabel; NewColor : TColor);
const
  GlowSteps = 10;
  ToColor : TColor = clHighLight;
var
  FromColor : TColor;
  i : integer;
  fR,fG,fB : Byte;
  tR,tG,tB : Byte;
begin
  FromColor := ColorToRGB(ALabel.Font.Color);
  NewColor := ColorToRGB(NewColor);
  fR := GetRValue(FromColor) div GlowSteps;
  fG := GetGValue(FromColor) div GlowSteps;
  fB := GetBValue(FromColor) div GlowSteps;
  tR := GetRValue(NewColor) div GlowSteps;
  tG := GetGValue(NewColor) div GlowSteps;
  tB := GetBValue(NewColor) div GlowSteps;
  for i := 1 to GlowSteps do begin
    ALabel.Font.Color := RGB((fR*(GlowSteps-i)) + (tR*i),
                             (fG*(GlowSteps-i)) + (tG*i),
                             (fB*(GlowSteps-i)) + (tB*i));
    ALabel.Repaint;
    Sleep(20); // unless executed in a separate thread,
               // this will disrupt any ongoing action
  end;
end;

end then use in the OnMouseEnter() & OnMouseLeave() events like this:

procedure TForm1.Label1MouseEnter(Sender: TObject);
begin
     if (Sender is TLabel) then
       if Assigned(TLabel(Sender).OnClick) then
         GlowMe(TLabel(Sender),clHighLight);
end;

procedure TForm1.Label1MouseLeave(Sender: TObject);
begin
     if (Sender is TLabel) then
       if Assigned(TLabel(Sender).OnClick) then
         GlowMe(TLabel(Sender),clWindowText);
end;

You can create your own TGlowLabel that would do this for you automatically.

Jan Zdenek at 2/23/2012 1:04:54 PM -
The "ToColor" constant is redundant, you can remove it.
And also excuse any "typos" that I might have made, I'm becoming rather tired today...

Server Response from: ETNACODE01