Solved

Tpanel color

Posted on 2004-08-02
1
1,041 Views
Last Modified: 2008-01-09
How can i loop through all tpanels on a form to change the color?
0
Comment
Question by:KLOPEKS
1 Comment
 
LVL 12

Accepted Solution

by:
esoftbg earned 85 total points
ID: 11691397
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Buttons, StdCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Edit1: TEdit;
    ListBox1: TListBox;
    SpeedButton1: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
  private   { Private declarations }
  public    { Public declarations }
    procedure ChangePanelsColor(Cl: TColor);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ChangePanelsColor(Cl: TColor);
var
  I:      Integer;
begin
  for I := 0 to ComponentCount-1 do
    if (Components[I].ClassType=TPanel) then
      (Components[I] as TPanel).Color := Cl;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  ChangePanelsColor(clSkyBlue);
end;

end.

emil
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

22 Experts available now in Live!

Get 1:1 Help Now