Board index » delphi » Minimize application on form minimize?

Minimize application on form minimize?

I have an app which uses mostly modal forms.

Every so often my user needs to do something with another tool and they want
to minimize all the open forms in my application... they can minimize the
current one, but since the current form is modal the other forms cannot be
minimized.

Does this look like the correct way to allow my users to minimize the app by
clicking on the current form's minimize button? (for EVERY form!!!)

procedure TfrmTest.FormResize(Sender: TObject);
begin
  if (self.WindowState=wsMinimized) then
  begin
    Self.WindowState:=wsNormal;
    Application.Minimize;
  end;
end;

Thanks for the help!!!,
--Raymond

 

Re:Minimize application on form minimize?


Quote
> Every so often my user needs to do something with another tool and they want
> to minimize all the open forms in my application... they can minimize the
> current one, but since the current form is modal the other forms cannot be
> minimized.

> Does this look like the correct way to allow my users to minimize the app by
> clicking on the current form's minimize button? (for EVERY form!!!)

I would use a handler for the WM_SYSCOMMAND message and call
Application.Minimize instead of inherited when (msg.cmdtype and $FFF0) =
SC_MINIMIZE.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Minimize application on form minimize?


Peter,

Quote
>I would use a handler for the WM_SYSCOMMAND message and
>call Application.Minimize instead of inherited when (msg.cmdtype
>and $FFF0) = SC_MINIMIZE.

I hate it when my ignorance shows!!!<G> but I have read your response over
and over and I still have no idea as to how you would handle this...

Do you think that you could make your description a bit more "idiot
proof"... I am 15 year veteran of more databases than I care to remember,
but when it comes to Windows messaging, I head for cover<VBG>.

Thanks,
--Raymond

Re:Minimize application on form minimize?


Quote
> Do you think that you could make your description a bit more "idiot
> proof"... I am 15 year veteran of more databases than I care to remember,
> but when it comes to Windows messaging, I head for cover<VBG>.

Raymond,

you add a handler declaration to your form this way:

  private // form declaration
    Procedure WMSyscommand(Var msg: TWmSysCommand);
      message WM_SYSCOMMAND;

Procedure TFormX.WMSyscommand(Var msg: TWmSysCommand);
  Begin
    Case (msg.cmdtype and $FFF0) of
      SC_MINIMIZE: Begin
          Application.Minimize;
          msg.result := 0;
        End;  
      Else
        inherited;
    End;
  End;

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Re:Minimize application on form minimize?


Peter,

Thanks a ton!!! Even I can handle that<VBG>!!

--Raymond

Re:Minimize application on form minimize?


Raymond,

On your base form of your application in which all forms are inheirted add:

private
    procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
    ....

procedure TfmMain.WMSysCommand(var Msg: TWMSysCommand);
begin
  if Msg.CmdType = sc_minimize then
     Application.Minimize
  else
     inherited;
end; // procedure TfmMain.WMSysCommand

If not inheriting from a base form, you'll need to add this code to each
form individually.

Gene McCrory
Nichols Infotec
http://www.nicholsinfotec.com
mccro...@nichols.com

Quote
Raymond J. Schappe wrote in message <7j5c5i$ka...@forums.borland.com>...
>I have an app which uses mostly modal forms.

>Every so often my user needs to do something with another tool and they
want
>to minimize all the open forms in my application... they can minimize the
>current one, but since the current form is modal the other forms cannot be
>minimized.

>Does this look like the correct way to allow my users to minimize the app
by
>clicking on the current form's minimize button? (for EVERY form!!!)

>procedure TfrmTest.FormResize(Sender: TObject);
>begin
>  if (self.WindowState=wsMinimized) then
>  begin
>    Self.WindowState:=wsNormal;
>    Application.Minimize;
>  end;
>end;

>Thanks for the help!!!,
>--Raymond

Re:Minimize application on form minimize?


Gene,

Thanks for the info... I am beginning to see the light!!!<G>

--Raymond

Other Threads