Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

TDesktopCanvas - draw on Windows Desktop

By Zarko Gajic, About.com

This canvas class allows you to access the Windows Desktop, and draw on it.

~~~~~~~~~~~~~~~~~~~~~~~~~
type
   TDesktopCanvas = class(TCanvas)
   private
     DC : hDC;
     function GetWidth:Integer;
     function GetHeight:Integer;
   public
     constructor Create;
     destructor Destroy; override;
   published
     property Width: Integer read GetWidth;
     property Height: Integer read GetHeight;
   end;

{ TDesktopCanvas object }
function TDesktopCanvas.GetWidth:Integer;
begin
   Result:=GetDeviceCaps(Handle,HORZRES) ;
end;

function TDesktopCanvas.GetHeight:Integer;
begin
   Result:=GetDeviceCaps(Handle,VERTRES) ;
end;

constructor TDesktopCanvas.Create;
begin
   inherited Create;
   DC := GetDC(0) ;
   Handle := DC;
end;

destructor TDesktopCanvas.Destroy;
begin
   Handle := 0;
   ReleaseDC(0, DC) ;
   inherited Destroy;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Hiding Minimized MDI Child Windows
« Get Last Day in Month

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming

About.com Special Features

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2001 Delphi Tips
  7. TDesktopCanvas - draw on Windows Desktop

©2009 About.com, a part of The New York Times Company.

All rights reserved.