I want to remove or disable the buttons inside the main menu, that controls the child form (minimize, restore), of my application.
The application should look like a "browser", where the MDI child forms must stay maximized all the time.
I alreday tried to disable they, by setting
BoderIcons := [biSystemMenu];
But I got this:
I alreday tried to disable the menu commands at the WM_INITMENU message, but without success:
procedure WMInitMenu(var Message: TWMInitMenu); message WM_INITMENU;
procedure TMyMDIChildForm.WMInitMenu(var Message: TWMInitMenu);
begin
inherited;
EnableMenuItem(Message.Menu, SC_MAXIMIZE, MF_BYCOMMAND or MF_GRAYED);
EnableMenuItem(Message.Menu, SC_MINIMIZE, MF_BYCOMMAND or MF_GRAYED);
end;
I'm using:
I solved by intercepting the WM_COMMAND at the MainForm as the follow code shows:
type
TMDIMainForm = class(TForm)
protected
procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
end;
implementation
procedure TMDIMainForm.WMCommand(var Message: TWMCommand);
begin
case Message.ItemID of
SC_CLOSE, SC_MINIMIZE, SC_RESTORE, SC_MAXIMIZE:
begin
Message.Result := 0;
Exit;
end;
else
inherited;
end;
end;
At the child forms, I simple placed this:
procedure TMDIChild.OnCreate(Sender: TObject);
begin
WindowState := wsMaximized;
end;
Now my MDI childs stays maximized and the user isn't able to restore or minimize than.