How to grayscale a complete Form..?

Hi Experts,
my actual problem is, that I've no plan, how to get the above result. The background: I have an indvidual colored MainForm with some colored content (eg. buttons or toolbars). I'd like, to grayscale this complete form every time, when there is showing a smaller, modal form in the front and to color it back after closing it. Can U help ?
Brainwashed2Asked:
Who is Participating?
 
pcsentinelCommented:
Something like

var
  li: integer;
begin
  for li:=0 to pred(Controlcount) do
  begin
    if Controls[li] is TPanel then
    begin
      Controls[li].Tag:=(Controls[li] as TPanel).Color;
      (Controls[li] as TPanel).Color:=clBtnFace;
    end;
  end;
  Form2.ShowModal;
  for li:=0 to pred(Controlcount) do
    if Controls[li] is TPanel then
      (Controls[li] as TPanel).Color:=Controls[li].Tag;
end;

simplified code compared to what you might need, unfortunatley the color property is protected in TControl so you have to be a bit more specific about the controls

regards
0
 
pcsentinelCommented:
One idea would be to have a procedure that is called when the form looses focus, this function runs though all of the components and copies the color to the componenets tag property, then changes the colour to clBtnFace, then when the form bemoces active again it reverses the process.
0
 
Brainwashed2Author Commented:
Thanks  pcsentinel ! That's exactly what I needed.  

regards,
brainwashed2
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.