Solved

MDI child minimized/maximized problem

Posted on 2004-09-11
7
2,101 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 65
oracle global variables 4 76
Multiple image collision 13 80
Firemonkey android show image from resource ? 1 46
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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