Since WM_SIZE will not be called on a mainform of a project not using the setting Application.MainFormOnTaskbar := True;
I'd suggest an approach, inspired by inspired by @kobik 's answer on , How to detect when the form is being maximized?.
WM_WINDOWPOSCHANGING will be called independed from MainFormOnTaskbar with different signatures on Message.WindowPos^.flags and respond on WIN + M too.
procedure TForm3.WMWindowPosChanging(var Message: TWMWindowPosChanging);
const
Hide1=(SWP_NOCOPYBITS or SWP_SHOWWINDOW or SWP_FRAMECHANGED or SWP_NOACTIVATE);
Hide2=((SWP_HIDEWINDOW or SWP_NOACTIVATE or SWP_NOZORDER or SWP_NOMOVE or SWP_NOSIZE));
begin
inherited;
if ((Message.WindowPos^.flags AND Hide1) = Hide1)
or ((Message.WindowPos^.flags AND Hide2) = Hide2) then
begin
Memo1.Lines.Add('Window got minimized');
end;
end;