delphi how to prevent a MDI child from being maximized?

985 views Asked by At

in delphi mdi application there is need to show a child window with its caption in Mainform client area when maximize button is pressed using

Win32Check(Windows.GetClientRect(ClientHandle, aTRect));

MDIChild1.BoundsRect := aTRect;

functions.

So, how we can prevent a MDI child from being maximized when maximize button is pressed?

I've tried to do it using

procedure TChildText.WMSYSCOMMAND(var Message: TWMSYSCOMMAND);
var
  aTRect:TRect;
begin
  inherited;
  case message.CmdType of
    SC_MAXIMIZE: 
      begin
        Win32Check(Windows.GetClientRect(MainForm.ClientHandle, aTRect));
        BoundsRect := aTRect;
      end;
  end;
end;

with no result.

1

There are 1 answers

2
Avrob On
procedure TChildText.WMSYSCOMMAND(var Message: TWMSYSCOMMAND);
var
  aTRect:TRect;
begin
  if message.CmdType = SC_MAXIMIZE then
  begin
    Win32Check(Windows.GetClientRect(MainForm.ClientHandle, aTRect));
    BoundsRect := aTRect;
    message.CmdType := SC_RESTORE;
  end;
  inherited;
end;