Location information of MDI child forms

S

Sebastian Daser

Hi all,

I have made a similar post before, but did not get any reply.
PLEASE HELP.

I have written an application that consists of an MDI container form with
MDI Children. When an MDI child form is closed I am storing the Location
property in order to restore the window's location when a window of the same
type is opened again. This works fine as long as the user does not scroll
the client area of the MDI container.

When the user scrolls the client area I am storing wrong locations, since
the Location property of the MDI Children is relative to the upper left
corner of the visual region of the client area. But I need to determine the
Location relative to the virtual region of the client area.

In order to calculate this I would like to detect the offset of the virtual
region of the client area.

Does anyone have an idea how to achieve this?

Any help would be greatly appreciated.

Thanks,
Sebastian.
 
G

Guest

Have you looked at
this.VerticalScroll.Value
(where this is the mdiparent form)
This should give you the number of pixels scrolled down.

Ciaran O'Donnell
 
S

Sebastian Daser

Hi Ciran,

The VerticalScroll and HorizontalScroll properties are useful for normal
forms, when the controls on the form exceed the rectangle of the form, so
that the contents of the form a scrolled.

However for an MDI-form these properties are always zero.

I have now come across the idea to loop through all child windows. The Left
position of the left most window should be the left offset and the top
position of the top most window should be the top offset.

If you know a better, more direct way please let me know.

Anyway, thanks for your input.

Kind regards,
Sebastian.
 
G

Garry

It seems that Microsoft does not want us to build applications using MDI
principals in VS2005 so the material which can help us fools is not really
available and most posts concerning positioning of MDI child forms go
completely unanswered by 'Microsoft people'.
I had a hell of a time loading my MDI children to fill the shadowy
ClientRectangle.
Material about the ClientRectangle appears in 'Microsoft Speek' which means
that it is gibberish to most programmers and of no help at all.
Fortunately, I do not have the problem of restoring an MDI child to its
previously loaded position but have you tried to initially load a child so
that it completely occupies the available space in the ClientRectangle
WITHOUT causing the scroll bars to appear.
That in itself took me 2 weeks of messing around with no help from posts
that I wrote.
It was all so simple in VB6.
I will watch your post to see if anyone else tries to help. Good luck

Garry
 
G

Guest

You dont need the scroll stuff. If you position the windows exactly as you
find them, then you will recreate the look precisely. If you scroll the mdi
container down to a form thats off the bottom, it actually moves the forms up
rather than scrolling the control.
Strang but true

Ciaran O'Donell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top