After doing some further digging I've come across the problem. @Remy please see below.
I am using TActionMainMenuBar in place of a TMainMenu on the parent MDI form. The TActionMainMenuBar handles the minimize/restore/maximize button clicks differently than that of TMainMenu. The code below is from the Vcl.ActnMenus file:
type
TInternalMDIAction = class(TWindowAction)
private
{ Private declarations }
public
{ Public declarations }
procedure ExecuteTarget(Target: TObject); override;
end;
procedure TInternalMDIAction.ExecuteTarget(Target: TObject);
begin
case MDIAction of
maActivate: SendMessage(GetParent(Form.Handle), WM_MDIACTIVATE, Form.Handle, 0);
maClose: Form.Close;
maRestore: SendMessage(GetParent(Form.Handle), WM_MDIRESTORE, Form.Handle, 0);
maMinimize: ShowWindow(Form.Handle, SW_MINIMIZE);
end;
end;
I am unable to catch the minimize event because WMSysCommand is never called by ShowWindow. I have included my fix below:
type
TInternalMDIAction = class(TWindowAction)
private
{ Private declarations }
public
{ Public declarations }
procedure ExecuteTarget(Target: TObject); override;
end;
procedure TInternalMDIAction.ExecuteTarget(Target: TObject);
begin
case MDIAction of
maActivate: SendMessage(GetParent(Form.Handle), WM_MDIACTIVATE, Form.Handle, 0);
maClose: Form.Close;
//maRestore: SendMessage(GetParent(Form.Handle), WM_MDIRESTORE, Form.Handle, 0);
//maMinimize: ShowWindow(Form.Handle, SW_MINIMIZE);
maRestore: SendMessage(Form.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
maMinimize: SendMessage(Form.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
end;
It is now performing as I would expect it to. If anyone sees something I might have missed or a better way of fixing the problem caused by VCL TActionMainMenuBar please let me know. Thanks.