Solved

MDI child minimized/maximized problem

Posted on 2004-09-11
7
2,122 Views
Last Modified: 2008-01-16
I have an MDI app in which I want to open the first MDI child window in a maximized state.
I also want to set the width and height of the child window (when it is first loaded) so that if/when the user "restores" the MDI child (i.e. un-maximizes it) then it will resize to the width and height previously set.

My code currently does this:
1. Create the MDI child form.
2. In the Form Show event, load the required WindowState (wsMaximized or wsNormal) state from a config file and set the MDI child window's WindowState accordingly.
3. In the Form Show event, load the required width and height from a config file and set the MDI child's width and height accordingly.

Now the Problem...

When I set the width of the maximized MDI child window, it becomes un-maximized.
So, how can I set the width without un-maximizing the MDI child window?

Ideally, I want to be able to create the *first* MDI child window in a maximized state, *and* set it's width and height (and left and top) so that when a user unmaximizes the MDI child window it is positioned and resized to the appropriate position and size.

Thanks
Paul
0
Comment
Question by:zebada
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 12033981
If I am correct it is like this: When the use restores from maximized the form will get the width/height in which it is designed in the IDE.

Regards Jacco
0
 
LVL 10

Assisted Solution

by:Jacco
Jacco earned 167 total points
ID: 12033993
Sorry, I wrong things are actually a bit more complicated...
0
 

Accepted Solution

by:
a_minde earned 167 total points
ID: 12034011
I have done this and it works fine.
1. In the IDE, make sure the form's Windowstate is wsNormal
2. In the form's OnShow event, first set the width and height as loaded from your configs.
3. Then, In the form's OnShow event, set the windowstate to the wsMaximized
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:zebada
ID: 12036753
Hi Jacco,

That is exactly what I am doing - the problem with that is this:
If I open up a second copy of the child window then it shows up as maximized (because the current child state is maximized).
Then I set the width and height in the onshow event and all the child windows become "normal"
Then I set the state to maximized and all the child windows go back to maximzed.
The Maximized->Normal->Maximized cycle of the display is disconcerting and looks really *bad*.

What I am trying to find out is how to set the width and height *without* also setting the windowstate to normal as a side effect.

Regards
Paul
0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 166 total points
ID: 12053159
Hi,

Move the code in MDIChild's OnCreate event instead and in the following order:

1. Read and set width and height properties
2. Read and set WindowState property

Now, all the parameters have already been set when the form is being shown.

Regards, Geo
0
 
LVL 6

Author Comment

by:zebada
ID: 13342209
I ended up going with a different solution. I used
LockWindowUpdate(Handle);
and
LockWindowUpdate(0);
Around the MDI child form creation code which solved the problem.

Split the points between the three replies - at least you guys bothered to answer me :)
Thanks
Paul


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question