Author: Jonas Bilinkevicius
My application (non MDI) has many modal forms which are open most of the time. When
the user wants to minimize the application and presses the minimize system button,
he experiences only the top modal form gets minimized while the other forms (at
least app's main form) are still at their current size. Moreover, the user now is
confused because clicking on the main form does nothing but giving errors to him. I
can not change the application's appearance or exchange the modal forms to some
other solution. Is there a way I can keep my modal design and still enable users to
minimize the application the way they are used to?
Answer:
Add a handler for WM_SYSCOMMAND to your modal forms. The handler should look like
this:
1 private{form declaration}2 3 procedure WMSyscommand(var msg: TWmSysCommand); message WM_SYSCOMMAND;
4 5 procedure TForm2.WMSyscommand(var msg: TWmSysCommand);
6 begin7 case (msg.cmdtype and $FFF0) of8 SC_MINIMIZE:
9 begin10 msg.result := 0;
11 EnableWindow(Application.handle, true);
12 Application.Minimize;
13 end;
14 else15 inherited;
16 end;
17 end;