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

Making a transparent form

By Zarko Gajic, About.com

Add a Button (Button1) to a Delphi form (Form1)...

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.FormCreate(Sender: TObject) ;
var
   FullRgn, ClientRgn, ButtonRgn: THandle;
   Margin, X, Y: Integer;
begin
   Margin := (Width - ClientWidth) div 2;
   FullRgn := CreateRectRgn(0, 0, Width, Height) ;
   X := Margin;
   Y := Height - ClientHeight - Margin;
   ClientRgn := CreateRectRgn
     (X, Y, X + ClientWidth, Y + ClientHeight) ;
   CombineRgn(FullRgn, FullRgn, ClientRgn, RGN_DIFF) ;
   X := X + Button1.Left;
   Y := Y + Button1.Top;
   ButtonRgn := CreateRectRgn
     (X, Y, X + Button1.Width, Y + Button1.Height) ;
   CombineRgn(FullRgn, FullRgn, ButtonRgn, RGN_OR) ;
   SetWindowRgn(Handle, FullRgn, True) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Rotating Text
« Add documents to the Windows Start-Documents Menu

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

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

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 1999 Delphi Tips
  7. Making a transparent form

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

All rights reserved.