• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

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 ?
0
Brainwashed2
Asked:
Brainwashed2
  • 2
1 Solution
 
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
 
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
 
Brainwashed2Author Commented:
Thanks  pcsentinel ! That's exactly what I needed.  

regards,
brainwashed2
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now