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

How to draw transparent text on Windows Desktop.

By , About.com Guide

Here's how to draw transparent text on the Windows Desktop:

~~~~~~~~~~~~~~~~~~~~~~~~~
{
Usage:
   DrawTextOnDesktop('About Delphi Programming'):
}

procedure DrawTextOnDesktop(TextToDraw: string) ;
var
   Handle: HWND;
   Dc: HDC;
   ACanvas: TCanvas;
begin
   Handle := GetDesktopWindow;
   Dc := GetWindowDC(Handle) ;
   ACanvas := TCanvas.Create;
   try
     ACanvas.Handle := DC;
     BeginPath(ACanvas.Handle) ;
     ACanvas.Font.Color := clRed;
     ACanvas.Font.Name := 'Tahoma';
     ACanvas.Font.Size := 30;
     SetBkMode(ACanvas.Handle, TRANSPARENT) ;
     EndPath(ACanvas.Handle) ;
     ACanvas.TextOut(0, 0, TextToDraw) ;
   finally
     ReleaseDC(Handle, ACanvas.Handle) ;
     ACanvas.Free;
   end;
end;

~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to delete an item from a dynamic (string) array
« How to load HTML directly to a WebBrowser

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2004 Delphi Tips
  7. How to draw transparent text on Windows Desktop.

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

All rights reserved.