I am in need of some help trying to capture the minimize event of an MDI Child form when it is maximized.
I am able to capture the minimize/restore/maximize events when the form is not maximized when clicking the buttons circled in red in the image below.
I capture the aforementioned events by using WMSysCommand:
procedure TMDIChildForm.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_MINIMIZE then
begin
//my code here
end;
end;
When I try to capture the same events using WMSysCommand when the MDI Child form is maximized and clicking the buttons circled in red in the image below, it will not call this code.
No matter what I have tried I have been unsuccessful in catching these events. If someone could point me in the right direction it would be greatly appreciated. Thank you.
Works fine for me when I try it:
WMSysCommand()
does capture theSC_MINIMIZE
notification whenever the MDI child is minimized, regardless of whether it was previously maximized or not, as expected.Make sure
TMDIChildForm.WMSysCommand()
callsinherited
(as shown above) to pass theWM_SYSCOMMAND
message to the default handler so Windows has a chance to process it.