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 ?
avast.JPG
AgentAmineAsked:
Who is Participating?

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

x
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.

pgnatyukCommented:
Actually there is a special API - EnableWindow that enable or disable the mouse and keyboard input:
http://msdn.microsoft.com/en-us/library/ms646291(VS.85).aspx

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:
http://www.codeproject.com/KB/winsdk/AntonioWinLock.aspx

You can use hooking, if you need. For example, here a way proposed by Microsoft:
http://support.microsoft.com/?kbid=226359

There is a special style: WS_EX_TOPMOST
I think you simply need to use this style.
http://msdn.microsoft.com/en-us/library/ms632680(VS.85).aspx

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
http://delphi.about.com/od/formsdialogs/l/aa073101b.htm

0
CodedKSenior Software EngineerCommented:
Hi AgentAnime,

I've uploaded an example here:

www.jump.fm/LXPMI

Hope this will help you. You can also disable desktop with enable disable window Api.
0
CodedKSenior Software EngineerCommented:
0
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:
0
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") !!
0
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);
var
  DeskTop : TCanvas ;
  X,Y: Integer;

begin
  DeskTop := TCanvas.Create ;
  Image1.Picture.Bitmap.Canvas.Brush.Style := bsSolid;
  Image1.Picture.Bitmap.Width := Screen.Width;
  Image1.Picture.Bitmap.Height := Screen.Height;
  try
    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))

  finally
    DeskTop.Free
  end;
  x := 0;
  y := 0;
  while y < Screen.Height do
  begin
    Image1.Picture.Bitmap.Canvas.MoveTo(0, y);
    Image1.Picture.Bitmap.Canvas.LineTo(Screen.Width, y+Screen.Width);
    Inc(y,2);
  end;
  while x < Screen.Width do
  begin
    Image1.Picture.Bitmap.Canvas.MoveTo(x, 0);
    Image1.Picture.Bitmap.Canvas.LineTo(x+Screen.Height, Screen.Height);
    Inc(x,2);
  end;
end;


Change :
WindowState property to wsMaximize.


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

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 ?
0
CodedKSenior Software EngineerCommented:
This is not hard i guess.
You ve got to set a timer and do 3 or 4 sequential passes.
0
cebassoCommented:
Hello,
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!

http://www.sunsetsolutions.com.br/priv/grayscreen.zip
Regards
0
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.

Regards
0
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
Delphi

From novice to tech pro — start learning today.