Forms Delphi

Title: Non-rectangular forms and controls
Question: How do I make a non-rectangular form?
Answer:
It's easy to make anything that descends from TWinControl any shape you want. All you need is a HRGN and the handle of the control. SetWindowRgn takes 3 parameters, the handle of the window to change, the handle to the region, and a boolean parameter to redraw or not after the change. Once you have a handle and a region, you can call SetWindowRgn(Handle, Region, True) and voil!
Here is an example using my BitmapToRgn function (as described in article ID #512).
Notice that you must not free the region with DeleteObject because the operating system owns the region after a call to SetWindowRgn.
var
MaskBmp: TBitmap;
begin
MaskBmp := TBitmap.Create;
try
MaskBmp.LoadFromFile('FormShape.bmp');
Height := MaskBmp.Height;
Width := MaskBmp.Width;
// The OS owns the region after call to SetWindowRgn
SetWindowRgn(Self.Handle, BitmapToRgn(MaskBmp), True);
finally
MaskBmp.Free;
end;
end;