How to draw transparent text on Windows Desktop

CK CK 3788 
Created at
Updated at  
416 0 0

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;
Tags DrawIcon DrawTextOnDesktop EndPath GetWindowDC SaveToFile Transparent Text Out Facebook X
Comments 0
Similar posts
  1. Extract an icon from an Windows application and paint on a Form
    416
  2. How to convert an ICO to a BMP
    363
  3. How to convert HIcon to TIcon ?
    448
  4. Get Cursor Image (draw it on a Canvas)
    681
  5. How to capture Windows Desktop to Bitmap
    560
  6. Grayscaling a bitmap ?
    533
  7. Cut a rectangle from an Image to Clipboard
    538
  8. Convert TColor to Hex & Hex to TColor
    592
  9. Implementing a lasso drawing technique
    385
  10. Convert a BMP to a JPG
    410
  11. Is Point in Polygon?
    368
  12. Paint a Form with a tiled bitmap image
    413
  13. Rotating Text
    448
  14. Show *any* graphics as Glyph on a SpeedButton
    542
  15. TColor to HTML color
    415
  16. TDesktopCanvas - draw on Windows Desktop
    558
  17. TImage.Bitmap fade out
    373
  18. Rotate Bitmap (any angle, any center of rotation)
    406
  19. How to draw Transparent Text on bitmap
    386
  1. Detecting Drive Types
    467
  2. Detecting and preventing Windows shut down
    439
  3. Copying Group of Files using Delphi with Standard Animation Dialog (SHFileOperation)
    413
  4. Controling sound volume from code
    424
  5. How to Close Another Application by Windows Caption
    390
  6. How to Change the Windows Start button bitmap
    428
  7. How to capture the output from a DOS (command/console) Window
    965
  8. How to Activate/Deactivate the Screen Saver
    863
  9. Retrieving all image links from an HTML document
    419
  10. List All Network Drives
    392
  11. How to set the "home page" for the Internet Explorer from Delphi code
    431
  12. How to get get IE favorites
    454
  13. Extracting the domain (host) name from an e-mail address
    488
  14. Download a file from the Internet with progress indicator
    553
  15. Are we connected to the Internet?
    422
  16. How to draw rotated text
    1,333
  17. How to Convert Pixels to Millimeters
    622
  18. Reading a directory content
    443
  19. Path shortener: c:\ABC...DEF.ghi
    443
  20. How to Split and Merge Files
    621
  21. Get File 'Last Modified' attribute
    466
  22. From/to the 8.3 (short) format to/from the long format
    581
  23. Delete folders recursively
    423
  24. Delete files with the ability to UNDO
    439
  25. Does my CD-ROM drive contain an audio CD?
    364
  26. Convert a mapped drive to a full UNC path
    833
  27. Checking If File Is In Use
    922
  28. Browse for Computers, Folders, Files and Printers
    571
  29. How Do I Remove The Application Icon From The Taskbar?
    1,099
  30. How To Show The Print Dialog And Print Text Files
    1,295
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    42
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    36
  3. How do I create animated background for Google Meet?
    21,041
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    252
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    515
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    288
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    232
  16. TPU & GPU Cluster Management Tools
    245
  17. The Concept of Scaffolding in AI Agents
    234
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    259
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    222
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    221
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    196
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    219
  30. Understanding Data Lineage
    263