Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

Create round windows

Title: Create round windows Question: How to create a round form with delphi's TForm ? Answer: The SetWindowRgn function sets the window region of a window. The window region determines the area within the window where the operating system permits drawing. The operating system does not display any portion of a window that lies outside of the window region. Simply use this function in the FormCreate event: procedure TForm1.FormCreate(Sender: TObject); var r1,r2 : HRgn; begin r1 := CreateEllipticRgn(1, -1, Width - 1, Height); r2 := CreateEllipticRgn(50, 50, Width - 50, Height - 50); CombineRgn(r2, r1, r2, RGN_XOR); SetWindowRgn(handle, r2, True) end;