By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,932 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,932 IT Pros & Developers. It's quick & easy.

Weird VB MDI Child Form - and fix.

P: n/a
Something I have run into using VB Express 2005 with mdi forms.

I have not been able to re-create this but I'll let out the information on
how I came about fixing this. As it cost me about 4 hours last night so it
might be a good read for anyone who uses mdi's.

1. I have Parent form that is an MDI conatainer. On the top of the form I
have a panel docked, and on the left hand side of the form I have a panel
docked with a splitter.
So form looks like


Where A is top Panel, with buttons such as A1, A2, A3 and so on.
B is right Panel ( lets forget about the splitter ) and C is where the MDI
childs will show.
C will be new forms, C1, C2, C3 that get called / opened / show() from
respective buttons A1, A2, A3...
In A i had 3 buttons that open up 3 seperate forms. Each form was set to
WindowState = Maximized ( on the properties ) of the form designer.

Click on Button 1A, form C1 displayed ok maximized in its "container"
Click on button 2A, form C2 displayed but not maximized. It displayed as
"normal", but its like it had the "maximized" state on, because if you hit
the "restore" button in the top right of the form, then it looked as if it
kinda repainted itself and stayed in "normal" windowstate. By clicking
maximize, the form maximized as it should have in the first place.
Also - If I were to change the border size ( with the mouse ) of the Parent
MDI Container form, the form C2 would instantly repaint itself maximized -
which is how it should have been painted in the fist place.

I hope this makes sence.

Even If I added / created a brand new form to my project and made a new
button A3, for form C3, I would get the same results.

**** If a form was already in "Maximized" mode and I tried to open another
form that would have the same problem, the new form would show properly.
Case 1 = C1 is now maximized, show C2, it shows properly.
Case 2 = No form is showing, C2 shows improperly.
Solution - after banging my head around,

Going to each form, setting its WindowState ( in designer ) to Normal, and
saving and compiling, and right before the command I did the
FormName.WindowState = Maximized.
Once I did this the problem fixed itself.
Even just by going to the properties and setting the WindowState to Normal,
saving and then back to Maximized, the problem fixed itself.

This had to be done with each form that had the problem.

I have tried to create a new solution, and tried to re-create this and could
not. But I know I wasnt dreaming for the 4 hours last night trying to
figure out why "Some" of my forms wouldnt show maximized and others would.

Basically now I keep all forms in "Normal" mode and I set the windowstate by
code. :-)


Oct 4 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.