Search code examples
delphibuttondelphi-7vcltbutton

Delphi TButton component styling


I just want to apologize in advance if this question is already in another thread. I am also relatively new to Delphi.

Today I have seen an example Delphi program that has TButton components on it. The buttons have a pulsating blue effect that I assume is part of the Windows styling. There is absolutely no code written to make the button this way. I have searched for a possible setting but to no avail.

Note: The buttons make the effect at run-time and there are no custom components installed.

If someone could give me some information about how to do this without code, maybe just a setting would be great.

I am using Delphi 7 (2002).


Solution

  • Delphi Firemonkey (FMX) component framework has a TColorAnimation for which you can set properties like Duration, StartValue, StopValue, trigger etc. The FMX framework was introduced in Delphi XE2.

    Blinking button demo


    Now that you have clarified that you use Delphi 7 (please remember in future to indicate the version), here's an alternative that works in Delphi 7 (FMX is not compatible with Delphi 7)

    var
      b: boolean;
    
    procedure TForm9.Timer1Timer(Sender: TObject);
    begin
      b := not b;
      if b then
        Button1.Perform(BM_SETSTATE, 0, 0)
      else
        Button1.Perform(BM_SETSTATE, 1, 0);
    end;
    

    Flashing is controlled by a TTimer, e.g 500 ms.

    However, this doesn't fulfill your requirement of "There is absolutely no code written to make the button this way.", but I'm not aware of any way to achieve that.