Maximised MDIchild form

I have an MDIchild form that is created at runtime.  The windowstate of the MDIchild is wsMaximised.  When the button is pushed that has to create the form, the form first become visible.  After that it resize (wsMaximised).  It seems like slowmotion.  What do I have to do to make shore that when the window is become visible (created), it already is maximised so the screen stays stable.

All suggestions welcome,
Dirk.

PS sorry for my poor English.
ka1aAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

men xinCEOCommented:
i test it ,but no problem.

menxin
0
pablocastaCommented:
I think there's no way to do it, unless not an easy way.

:} Pablo.
0
pablocastaCommented:
Yeah, the problem exists, and though it's not too low it seems to be so.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Roadrunner100598Commented:
Listening...
0
karooCommented:
ka1a,

this is the best i was able to do:

MDIForm => Form1
MDIChild => Form2

set the WindowState property of Form2(MDIchild) to wsNormal at design time and add the the following code in the on create event of Form2:
procedure TForm2.FormCreate(Sender: TObject);
begin
  Height:= Form1.ClientHeight;
  Width:= Form1.ClientWidth;
  Left:= Form1.Left;
  Top:= Form1.Top;
end;

now when you create Form2 at runtime:
  Form2:= TForm2.Create(Application);
  Form2.Show;
  Form2.WindowState:= wsMaximized;

most of the resizing will be done in the create of the MDIChild. It helps, although it is not perfect.

Regards Ben:)
0
Roadrunner100598Commented:
18 pts - you should really increase that! This is a hard one.

How about...

procedure MainForm.MenuItem1Clicked(sender:TObject);
begin
  LockWindowUpdate(self.Handle);
  try  
    TMyMDIChild.Create(self);
  except
    { ??? }
  end;
  LockWindowUpdate(0);
end;

This stops your program from updating the screen, so you just don't see the exffects. But in any case unlock the window afterwards (that's what the try.. except is for).

Beep, beep,... Roadrunner

Btw: I tested some other ways, but always ended up with the same behaviour as described. If you look into the VCL sources you'll find, that Delphi calls a routine 'SetWindowToMonitor' that adjusts some coordinates - after that the window is made visible. Obviously this happens before the WindowsState gets set. So the window is first shown in wsNormal and then changed to wsMaximized. I experimented with ShowWindow, even found a way to have an inivisible MDI-Child after creation, but the flashing still remained. So I removed the symptom, but not the cause.

0
karooCommented:
nice workaround Roadrunner:)

yep saw the VCL code.
any idea why a MDIChild's visibility can't be false or why it's position is changed to poDefault in the SetFormStyle method?

It's interesting that Delphi controls MDIChild form's so rigidly - or is that necessary.
0
Roadrunner100598Commented:
Nope, I guess it's to make our work easier. Normally MDI works nice except for this minor issues... :(

During working on your question I tried to override TMDIForm.CreateParams. If you add Visible:=false to the method you end up with an invisible MDI-Child. But the very moment you set Visible:=true all is back to normal - flashing, popping an all.
0
karooCommented:
Roadrunner,

>>working on your question
nope it's not mine, just interested in it:)
So you can actually change the visibility in CreateParams, interesting, i'll try it out also.
0
Roadrunner100598Commented:
Oops, no offend mend... I just didn't really look at the name.
0
ptmcompCommented:
Delphi normally switches off the resize effect that you can see while minimizing a form, for the MDIChildren it doesn't. That's the reason because it takes so much time to maximize a child form - even if you used LockWindowUpdate.
Regards, ptm.
0
AttarSoftwareCommented:
MDI sucks, and has sucked since its birth...  It sucks so bad, that even Microsoft try and steer clear of it.  As soon as you try and resize windows, etc, it doesn't work right...

We had to stop using MDI.

No good news, only news.

Tim.
0
Roadrunner100598Commented:
Hey Tim, can you be more specific? I had not too much trouble with MDI.
0
ka1aAuthor Commented:
Hello,

I have increased the points to 48.  I don't know of this will help.

Tricks are also oké.  By example: is it posible to create the form in the back and after the resizing is done (wsMaximize) to bring it in front?  Anything is oké, as long as the resizing is not visible.

Please, tricks are oké, as long it will not make the application a lot slower, or use a lot of memory more and so on ...  

All suggestions welcome.

Dirk.
0
Roadrunner100598Commented:
There is no way of doing wsMaximize in the background unless you want to recompile the VCL...  :(   (see discussion with karoo and look in the sources yourself)

Just accept my solution (above)  - that's as good as it can get.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DoruIlasiCommented:
You should create your MDIChild form like this:

  SendMessage(Handle, WM_SETREDRAW, 0, 0);
  frmChild := TfrmChild.Create(Self);
  frmChild.WindowState := wsMaximized;
  SendMessage(Handle, WM_SETREDRAW, 1, 0);
  InvalidateRect(Handle, nil, TRUE );
  BringWindowToTop(Handle);

It will have no flickering because it will show the form only after all the visual modifications are made.
0
DoruIlasiCommented:
Sorry, my solution was not as good as the one with LockWindowUpdate by Roadrunner...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.