Hi!
I do not know if it helps, and shows the limitations that Mr. Graeme said.
I use form inheritance, and put this code to change some colors in the parent form:
procedure TForm_Basic.FormCreate(Sender: TObject);
var
l_integer_aux2, l_integer_aux3 : Integer;
Component : TComponent;
begin
inherited;
self.Color:=StringtoColor(DataModule_Base.a_string_cor_form);
for Component in Self do
begin
if Component is TDBGrid then
begin
TDBGrid(Component).ParentColor := false;
TDBGrid(Component).AlternateColor:=StringtoColor(DataModule_Base.a_string_cor_grid_ac);
TDBGrid(Component).Color:=StringtoColor(DataModule_Base.a_string_cor_grid_col);
for l_integer_aux2 := TDBGrid(Component).Columns.Count - 1 downto 0 do
begin
if not TDBGrid(Component).Columns[l_integer_aux2].ReadOnly then
TDBGrid(Component).Columns[l_integer_aux2].Title.Color:=StringtoColor(DataModule_Base.a_string_cor_grid_tit)
else
TDBGrid(Component).Columns[l_integer_aux2].Title.Color:=StringtoColor(DataModule_Base.a_string_cor_grid_tit_readonly);
end;
end
else if (Component is TLabel) then
begin
TLabel(Component).Color:=StringtoColor(DataModule_Base.a_string_cor_form);
end
else if (Component is TPageControl) then
begin
for l_integer_aux2 := TPageControl(Component).PageCount - 1 downto 0 do
begin
for l_integer_aux3 := TPageControl(Component).Pages[l_integer_aux2].ControlCount - 1 downto 0 do
begin
if (TPageControl(Component).Pages[l_integer_aux2].Controls[l_integer_aux3] is TPanel) then
begin
(TPageControl(Component).Pages[l_integer_aux2].Controls[l_integer_aux3] as TPanel).Color:=StringtoColor(DataModule_Base.a_string_cor_form);
end;
end;
end;
end;
end;
end;
Later, I decided to change the colors on the fly, and put a popup menu the color swap options from the main form of the application:
procedure TForm_Main.pc_PaintWindows();
var
l_integer_TotalForms, l_integer_aux1 : Integer;
l_integer_aux, l_integer_aux2, l_integer_aux3 : Integer;
begin
l_integer_TotalForms := screen.CustomFormCount;
for l_integer_aux1 := 0 to l_integer_TotalForms - 1 do
begin
//form
screen.CustomForms[l_integer_aux1].Color:=StringtoColor(DataModule_Base.a_string_cor_form);
for l_integer_aux := screen.CustomForms[l_integer_aux1].ComponentCount - 1 downto 0 do
begin
//ac grid
if (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] is TDBGrid) then
begin
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).ParentColor := false;
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).AlternateColor:=StringtoColor(DataModule_Base.a_string_cor_grid_ac);
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).Color:=StringtoColor(DataModule_Base.a_string_cor_grid_col);
for l_integer_aux2 := (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).Columns.Count - 1 downto 0 do
begin
if not (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).Columns[l_integer_aux2].ReadOnly then
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).Columns[l_integer_aux2].Title.Color:=StringtoColor(DataModule_Base.a_string_cor_grid_tit)
else
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TDBGrid).Columns[l_integer_aux2].Title.Color:=StringtoColor(DataModule_Base.a_string_cor_grid_tit_readonly);
end;
end
else if (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] is TStringGrid) then
begin
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).ParentColor := false;
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).AlternateColor:=StringtoColor(DataModule_Base.a_string_cor_grid_ac);
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).Color:=StringtoColor(DataModule_Base.a_string_cor_grid_col);
for l_integer_aux2 := (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).Columns.Count - 1 downto 0 do
begin
if not (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).Columns[l_integer_aux2].ReadOnly then
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).Columns[l_integer_aux2].Title.Color:=StringtoColor(DataModule_Base.a_string_cor_grid_tit)
else
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TStringGrid).Columns[l_integer_aux2].Title.Color:=StringtoColor(DataModule_Base.a_string_cor_grid_tit_readonly);
end;
end
else if (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] is TLabel) then
begin
(screen.CustomForms[l_integer_aux1].Components[l_integer_aux] as TLabel).Color:=StringtoColor(DataModule_Base.a_string_cor_form);
end
else if (screen.CustomForms[l_integer_aux1].Components[l_integer_aux] is TPageControl) then
begin
for l_integer_aux2 := TPageControl(screen.CustomForms[l_integer_aux1].Components[l_integer_aux]).PageCount - 1 downto 0 do
begin
for l_integer_aux3 := TPageControl(screen.CustomForms[l_integer_aux1].Components[l_integer_aux]).Pages[l_integer_aux2].ControlCount - 1 downto 0 do
begin
if (TPageControl(screen.CustomForms[l_integer_aux1].Components[l_integer_aux]).Pages[l_integer_aux2].Controls[l_integer_aux3] is TPanel) then
begin
(TPageControl(screen.CustomForms[l_integer_aux1].Components[l_integer_aux]).Pages[l_integer_aux2].Controls[l_integer_aux3] as TPanel).Color:=StringtoColor(DataModule_Base.a_string_cor_form);
end;
end;
end;
end;
end;
end;
end;
Probably the code should be unified to the above, to avoid duplications (I see this later - run first, optimize later).
You can add more properties of components that accept change colors.
See attached:
(google translator)