Hide the Minimize/Maximize buttons of a form

Spread the love

This article shows by example how to suppress the maximize and
minimize buttons on an form at runtime.
To disable an form’s Minimize and Maximize buttons,
you need to use the SetWindowLong Windows API
function to change the style of the window.

Add the following code to the OnCreate event
procedure for your form (TForm1):

procedure TForm1.FormCreate(Sender: TObject);
  l: DWORD;
  l := GetWindowLong(Self.Handle, GWL_STYLE);
  l := l and not (WS_MINIMIZEBOX);
  l := l and not (WS_MAXIMIZEBOX);
  l := SetWindowLong(Self.Handle, GWL_STYLE, l);