Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi resizable bsDialog Form?

How can I make a Form (ShowModal) with BorderStyle bsDialog. but one that could still be resized and have the close button (without the Icon,Minimize, Maximize)?

I do not need it to show the size grip.

like image 796
zig Avatar asked Sep 03 '25 05:09

zig


2 Answers

Here is my solution which seems to work OK:

type
  TForm2 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
  protected
    procedure CreateWnd; override;
    procedure CreateParams(var Params: TCreateParams); override;
  public
  end;

var
  Form2: TForm2;

implementation

{$R *.DFM}

procedure TForm2.FormCreate(Sender: TObject);
begin
  BorderIcons := [biSystemMenu];
  BorderStyle := bsSizeable;
  AutoScroll := False;
end;

procedure TForm2.CreateWnd;
begin
  inherited;
  SendMessage(Handle, WM_SETICON, 1, 0);
end;

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle or WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
end;

IMO, This cant be done with bsDialog but the above feels and looks just like a "bsDialog" which could be resized.

like image 163
zig Avatar answered Sep 04 '25 23:09

zig


Set the BorderStyle to bsSizeToolWin.

like image 28
Wosi Avatar answered Sep 05 '25 01:09

Wosi