minimize non-main forms to the taskbar
From: David Watt <bm01393@themis.ag.gov.bc.ca>
I posted a message a few weeks ago asking about how to minimize non-main forms
to the taskbar, or more precisely, how to minimize applications to the taskbar
from forms other than the main form. (I find the fact that secondary forms
minimize to the desktop really unappealing.) I received a number of replies
(and thanks for those) but no one had an answer. After a little surfing and
some trial-and-error I've come up with a solution.
In order to have secondary forms minimize the application to the taskbar all
you need are the following two steps.
1. Declare a private message handling procedure within the secondary form which
will intercept messages destine for the form.
--------------------------------------------------------------------------------
private
{ Private declarations }
procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMMAND;
--------------------------------------------------------------------------------
2. Create a procedure in the secondary form's implementation section which
intercepts messages and puts in place a substitution for SC_MINIMIXE messages
so that the Application.Minimize procedure is executed instead. All other
messages pass through normally; they are inherited.
--------------------------------------------------------------------------------
procedure TForm2.WMSysCommand(var Message: TMessage);
begin
if (Message.WParam = SC_MINIMIZE) then
Application.Minimize
else
inherited;
end;
--------------------------------------------------------------------------------
That's does the trick.
特别适合MDI