Capture the desktop image to a TImage  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 22/01/00

Tip accessed 593 times

 


  • Put a TImage (Image1) and a TButtom (Button1) in your form
  • Put this code into OnCLick event of Button1:


     procedure TForm1.Button1Click(Sender: TObject);
     var
       DeskTop : TCanvas ;
     begin
       DeskTop := TCanvas.Create ;
       try
         with DeskTop do
           Handle := GetWindowDC (GetDesktopWindow) ;
    
         with Image1.Canvas do
           CopyRect (Rect (0, 0, 200, 200),
                     DeskTop,
                     Rect (0, 0, 200, 200))
       finally
         DeskTop.Free
       end
     end;
    



    You can draw into any other object with canvas (in your form, in a TPaintBox, etc...)