Mega Code Archive

 
Categories / Delphi / Forms
 

Create a Resizable Delphi Form with No Border (FormStyle = bsNone)

Title: Create a Resizable Delphi Form with No Border (FormStyle = bsNone) By default, forms include maximize and minimize buttons, a resizable border, and a menu that provides additional commands to resize the form. The BorderStyle property of a Delphi Form object can be used to specify the appearance and behavior of the form border. The bsNone is used when you want to remove the Border and the caption bar from the form - leaving only the content visible. This setting is commonly used when creating a splash screen. One downside to setting the bsNone value for BorderStyle is that such forms cannot be resized! Resizable Without Border There may be situations when you want to remove a form's border (and title bar) *but* still leave the option for a user to resize the form. Screen Ruler uses the next trick to display a resizable + no-border window: //no border BUT resizable procedure TForm1.CreateParams(var Params: TCreateParams) ; begin BorderStyle := bsNone; inherited; Params.ExStyle := Params.ExStyle or WS_EX_STATICEDGE; Params.Style := Params.Style or WS_SIZEBOX; end; The trick is in overriding the CreateParams method!