question

GR15-6050 avatar image
0 Votes"
GR15-6050 asked GR15-6050 answered

How do I stop an MDI parent form from being resized when moved ?

I have an MDI form (VB.net) which contains about 10 child forms which are permanent and fixed in place and which take up nearly all the whole parent form except for a small margin around the edges and between child forms of about 2px. When I move the parent form, it resizes to a slightly smaller size resulting in the display of scroll bars which cover part of the child forms.
This is extremely annoying and cannot be undone by any programmatic means such as trying to set the form's size : me.Width = ... etc inside an event handler after the screen is moved or resized.

The form is set on the designer in Visual Studio as :
123349-image.png



This program represents many years work, and it is being held hostage by this behaviour, so any ideas would be greatly appreciated.

I have chosen to use child windows instead of using fixed panels, as the program allows those users with multi screens to undock the windows and move and resize them to other screens .

Thanks, Grant.

vs-generalwindows-formsdotnet-visual-basic
image.png (31.3 KiB)
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I don't see what you mean
If you only move a window, there is no reason why it would be resized, MDI or not : MDI Move


1 Vote 1 ·

Yes, you are right. If I set the window to show "NORMAL" instead of "MAXIMISED" in the properties window, then I get the scroll bars from the start, and when I move the form, nothing happens to the size. So it seems that starting off in maximised, when I move the screen it is automatically resized to normal.


OK. by reducing the windows size by about 30px along bottom and right edges of parent window, the scroll bars are no longer a problem, but I have lost this amount of screen area, which is now a 30 px border, so why the scroll bars in the first place ?

0 Votes 0 ·

MDI is not designed to be used in the manner you are using it. Beginners often make the mistake of thinking in the beginning that MDI is an easy solution but when the application evolves it becomes difficult to do things that would be easy to do using more appropriate solutions. You have invested time in the use of MDI and that is unfortunate.

0 Votes 0 ·

Thank you SimpleSamples for your comment.
I would prefer not to use MDI as I have learnt that it does not do what I want. I would appreciate it if you could see an alternative in my application. I am essentially trying to control 10 windows that need to work together, but leaving them floating on the desktop also has issues. If you set them all to topmost = true, then other apps cannot appear when required and error messages or message boxes are hidden which can cause the program to hang, as you cannot access them to click ok or cancel.
Doing away with separate windows altogether would be a massive task as the application has over 90,000 lines of code, much of it detailed graphics. A major feature of the program is the rearrangement and resizing of windows.

Any constructive comments would be welcome.

0 Votes 0 ·

Does it only happen when you move it to another monitor? What is the screen resolution in your case?

It seems that any window, which is maximised, is resized if moved.

Maybe you can arrange your child windows taking into consideration the smaller area that is set after moving. Then the scrollbars will not appear.

0 Votes 0 ·

Thanks, pls refer to my answer to Castorix above. Problem fixed at a cost of 30 px wide border along bottom and right edges.

0 Votes 0 ·

If I understand correctly, you deduced that the window, which is maximised, is resized if moved, and you arranged your child windows taking into consideration the smaller area.

Maybe you can handle the Resize event and reposition the child window programmatically according to new window size, avoiding lost of space; unless there are situations when this should not be done or should be done in a manner that activates scroll bars.


0 Votes 0 ·
Show more comments

1 Answer

GR15-6050 avatar image
0 Votes"
GR15-6050 answered

Problem fixed using window.owner = parent window instead of MDI.

No scroll bars or any other behind the scenes interference.

Everything works great and I have full control of window size and position.

Keep clear of MDI unless you know what you are doing.
Now I can get back to actual coding.

Thanks for your comments.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.