Mega Code Archive

 
Categories / Delphi / Forms
 

Get transparent form

Title: Get transparent form If you want to create form with transparent background, then you should override Create and Resize methods of your Form. CombineRgn function is basic function for realisation of this idea. constructor TForm1.Create(AOwner: TComponent); begin inherited; HorzScrollBar.Visible:=False; VertScrollBar.Visible:=False; NewWindowRgn; end; procedure TForm1.NewWindowRgn; var i, CoordX, CoordY: Integer; FormRgn, NewRgn: THandle; begin CoordX:=(Width-ClientWidth) div 2; CoordY:=Height-ClientHeight-4; FormRgn:=CreateRectRgn(0, 0, Width, Height); NewRgn:= CreateRectRgn( CoordX, CoordY, CoordX+ClientWidth, CoordY+ClientHeight); CombineRgn(FormRgn, FormRgn, NewRgn, RGN_DIFF); for i:= 0 to ControlCount -1 do with Controls[i] do begin NewRgn:= CreateRectRgn( CoordX + Left, CoordY + Top, CoordX + Left + Width, CoordY + Top + Height); CombineRgn(FormRgn, FormRgn, NewRgn, RGN_OR); end; SetWindowRgn(Handle, FormRgn, True); end; procedure TForm1.Resize; begin inherited; NewWindowRgn; end;