Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to capture the Desktop and shade it Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Oct-02
Category
System
Language
Delphi 2.x
Views
160
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

How to capture the Desktop and shade it

Answer:

This unit takes the Desktop and makes it look like it does when you select Shutdown 
from the Start menu. You need a TForm with BorderStyle set to bsNone and a TImage 
component set to alClient.

1   procedure TForm1.FormShow(Sender: TObject);
2   
3     procedure Veil;
4     var
5       BrushBmp: TBitmap;
6       X, Y: Integer;
7     begin
8       BrushBmp := TBitmap.Create;
9       with BrushBmp do
10      begin
11        Width := 8;
12        Height := 8;
13        for X := 0 to 7 do
14          for Y := 0 to 7 do
15            if Odd(X + Y) then
16              Canvas.Pixels[X, Y] := clWhite
17            else
18              Canvas.Pixels[X, Y] := clBlack;
19      end;
20      Image1.Canvas.Brush.Bitmap := BrushBmp;
21      {The PatBlt function paints the given rectangle using the brush that is 
22  		currently selected into the specified device context. 
23  		The brush color and the surface color(s) are combined by using the
24      given raster operation.}
25      PatBlt(Image1.Canvas.Handle, 0, 0, Image1.Width, Image1.Height, $000A0329);
26      BrushBmp.Free;
27    end;
28  
29  var
30    ScreenDC: HDC;
31    tmpRect: TRect;
32    tmpBitmap: TBitmap;
33  begin
34    {Set the form bounds}
35    SetBounds(0, 0, Screen.Width, Screen.Height);
36    {get our screen device context}
37    ScreenDC := GetDC(0);
38    {create our bitmap}
39    tmpBitmap := TBitmap.Create;
40    {get the screen area}
41    tmpRect := Rect(0, 0, Screen.Width, Screen.Height);
42    {set the bitmap to the screen area}
43    tmpBitmap.Width := tmpRect.Right - tmpRect.Left;
44    tmpBitmap.Height := tmpRect.Bottom - tmpRect.Top;
45    try
46      {transfer the screen pixels to the bitmap}
47      BitBlt(tmpBitmap.Canvas.Handle, tmpRect.Left, tmpRect.Top, tmpBitmap.Width,
48        tmpBitmap.Height, ScreenDC, tmpRect.Left, tmpRect.Top, SRCCOPY);
49      {assign the bitmap image to our TImage}
50      Image1.Picture.Bitmap.Assign(tmpBitmap);
51    finally
52      {free our bitmap}
53      tmpBitmap.Free;
54      {release our screen device context}
55      ReleaseDC(0, ScreenDC);
56    end;
57    Veil;
58  end;
59  
60  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC