Delphi - MainForm

danz67
danz67 used Ask the Experts™
on
I have two forms, FormAzienda and FormMain, the startup form and FormAzienda, after entering some values in open ShowModal the FormMain.
The problem is that if you iconify the FormMain, the FormAzienda can be seen in the background. I tried several ways but failed to close the FormAzienda.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
So, FormMain is your MainForm, and you open the FormAzienda as 'ShowModal'.

If so, then I don't understand how you can Minimize the MainForm before closing the FormAzienda.
When you show FormAzienda Modally, then you cannot click other forms before closing the FormAzienda.

Can you clarify a little bit please?
Thanks,

Wim.
Top Expert 2011

Commented:
Did you try to hide it ?

FormAzienda.hide;

Author

Commented:
Application.MainForm is FormAzienda
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Emmanuel PASQUIERFreelance Project Manager
Top Expert 2010

Commented:
wimmeyvaert, I think that is the opposite  , danz67 please correct me if I'm wrong :
the main form is FormAzienda, some values are entered (like a login)
and then only Main form is displayed as modal

If so, I would recommend Hiding FormAzienda before showing MainForm, and re-show it after ShowModal , something like this


procedure TFormAzienda.btnGoMain(Sender:TObject);
begin
 Hide;
 MainForm.ShowModal;
 Show;
end;

Open in new window

You could also prevent MainFormof being Minimized.
Normally, when you show a form modally, you really need to close the formbefore you can continue.
So, better set the 'BorderIcons' property of the MainForm.
Set biMinimize and biMaximize to False.

Best regards,

Wim.

Author

Commented:
- wimmeyvaert:
The solution to hide the button I do not like, thanks.

- epasquier:
I attach pictures of what happens after writing HIDE


azienda.bmp

Author

Commented:
2 image
FormMain.bmp

Author

Commented:
3 image
result.bmp

Commented:
hi

change the formStyle of mainform TO "fsNormal", both of them should be "fsNormal" in that kind of application system.

Mainform.formStyle := fsNormal;

You can change it in the form properties.

Author

Commented:
It's already to fsNormal
Top Expert 2011

Commented:
This behavior happens when you minimize any form that's not the main form.

What you can do is simply make FormMain your main form instead of FormAzienda then when you done with FormAzienda just close it (FormAzienda.close;)
That should fix your issue.
Freelance Project Manager
Top Expert 2010
Commented:
If you allow your MainForm to be minimized while it is shown , and you want in this case the azienda form to be visible and the user can interact with it, then MainForm should not be called with ShowModal but plain Show.
But then you will have to manage the possibility that more than one MainForm can be opened at the same time, and that will be messy. So really, the clean solution, that will be consistent with what users are used to with others applications, is to not allow the MainForm to be minimized. Or to minimize the whole application. Both would need that you manage the systeme command messages :
Type
 TMainForm=class(TForm)
...
  protected
    procedure WMSyscommand(Var msg: TWmSysCommand); message
WM_SYSCOMMAND; 
...
 end;

procedure TMainForm.wmsyscommand(var msg: TWMSyscommand);
begin
 if (msg.CmdType and $FFF0) = SC_MINIMIZE 
  then Application.Minimize
  else inherited;
end;

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial