Solved

MDI child minimized/maximized problem

Posted on 2004-09-11
7
2,035 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
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now