How to grayscale the screen for a period of time

Using Delphi 7

i want to fade the screen to gray to prevent user input, just like xp does when changing themes or Avast when disable shields. i want it to cover the whole screen including the taskbar, i will search in disabling user input later, but what i need is the fading to gray screen, any idea or code ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Actually there is a special API - EnableWindow that enable or disable the mouse and keyboard input:

I do not know if it will work for the desktop. Probably not. If you have a lot of memory, you can grab the desktop into a bitmap, make your own window that will cover the desktop and show this bitmap (with any graphic event).

Here is an article about such things:

You can use hooking, if you need. For example, here a way proposed by Microsoft:

There is a special style: WS_EX_TOPMOST
I think you simply need to use this style.

You can try to apply that:
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOPMOST);

You can read this article:
A more powerful Delphi Form

CodedKSenior Software EngineerCommented:
Hi AgentAnime,

I've uploaded an example here:

Hope this will help you. You can also disable desktop with enable disable window Api.
CodedKSenior Software EngineerCommented:
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

CodedKSenior Software EngineerCommented:
AgentAmineAuthor Commented:

@pgnatyuk:: thanks for your comment, the links are useful, but not exactly what i want

@CodedK : i appreciate your work, but i just could not compile it (using delphi 7, "image1.ExplicitWidth property does not exit") !!
CodedKSenior Software EngineerCommented:
This is an old Delphi 7 source i had in my folders... So it should work !

Create a Delphi 7 Form.
Inside drop an Image component and set its Align property to alClient.

On Form Create :

procedure TForm1.FormCreate(Sender: TObject);
  DeskTop : TCanvas ;
  X,Y: Integer;

  DeskTop := TCanvas.Create ;
  Image1.Picture.Bitmap.Canvas.Brush.Style := bsSolid;
  Image1.Picture.Bitmap.Width := Screen.Width;
  Image1.Picture.Bitmap.Height := Screen.Height;
    with DeskTop do
      Handle := GetWindowDC (GetDesktopWindow) ;

    with Image1.Picture.BitMap.Canvas do
      CopyRect (Rect (0, 0, Screen.Width, Screen.Height), DeskTop,
                        Rect (0, 0, Screen.Width, Screen.Height))

  x := 0;
  y := 0;
  while y < Screen.Height do
    Image1.Picture.Bitmap.Canvas.MoveTo(0, y);
    Image1.Picture.Bitmap.Canvas.LineTo(Screen.Width, y+Screen.Width);
  while x < Screen.Width do
    Image1.Picture.Bitmap.Canvas.MoveTo(x, 0);
    Image1.Picture.Bitmap.Canvas.LineTo(x+Screen.Height, Screen.Height);

Change :
WindowState property to wsMaximize.

I just compiled it with Delphi 2007, this is the code you can write it and compile it

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AgentAmineAuthor Commented:
thanks CodedK, this is what iam looking for,
BUT, what about the fading motion ?
CodedKSenior Software EngineerCommented:
This is not hard i guess.
You ve got to set a timer and do 3 or 4 sequential passes.
Thanks @CodeK, i have searched for this too!
I have improved your code just a little... with the fade out effect and with other grayscale effect...
i don't wanna points for this!
AgentAmineAuthor Commented:

You helped me alot, so thanks to both of you

@cebasso : thanks for responding, your code was really usefullllll

@CodedK : You are right, this is not so hard to do,  forgive my ignorance,  i'm not a good programmer. the points are yours.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.