MDI Childwindows, center on screen problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi and thank you for taking the time to read about my problem.

I have a simple MDI parent form frmMain with a menu (file, edit, window,
help).
Under file you can create new childforms called SelectSample.

Under Window there are a bunch of (standard) options, like tile
horizontal/vertical and cascade. I also have an entry "Center Window".

What I want to obtain here is that when a childwindow exist (the check is
already in place). The activechildwindow will be centered in reference to the
parent MDI Form.

Now, the problems that I have met, while trying to implement this (at first
glance) trivial part of the program.

When my childwindow touches on of the sides of the main window it looks as
if the window is going to be docked left (doesn't matter which border I meet
left, right, top, bottom, only for 1px if I touch the border the window pulls
to left and resizes it's height as if it is going to be docked. When I pull
the window further over the border, the visualisation is ok.

That's the first part of the problem. The second one is the following.
With the center on screen menu item comes a bit of code in frmMain looking
like this:
Dim parentWidth As Integer = Me.Size.Width
Dim parentHeight As Integer = Me.Size.Height
Dim childWidth As Integer = Me.ActiveMdiChild.Size.Width
Dim childHeight As Integer = Me.ActiveMdiChild.Size.Height
Me.ActiveMdiChild.Left = ((parentWidth - childWidth) / 2) +
Me.Location.X
Me.ActiveMdiChild.Top = ((parentHeight - childHeight) / 2) +
Me.Location.Y

I already tried Me.ActiveMdiChild.Location = New Point (...)

But that didn't work either.

I also tried to manipulate the public overridable property X and Y, but the
compiler keeps telling me i'm trying to assign a value to a value
(Me.ActiveMdiChild.Location.X )

I know it's 2 problems at once, but I can't help but feel they are related.
I already tried making a menu in the child form and use me.left and me.right
locally but the menu's don't merge like I want them to.

This really is frustrating.

Thank you for your time and expertise,
With kind regards,
Ian Jorg Floren a.k.a. SL33PY
 
I can only help with one item:
Hi and thank you for taking the time to read about my problem.

I have a simple MDI parent form frmMain with a menu (file, edit, window,
help).
Under file you can create new childforms called SelectSample.

Under Window there are a bunch of (standard) options, like tile
horizontal/vertical and cascade. I also have an entry "Center Window".

What I want to obtain here is that when a childwindow exist (the check is
already in place). The activechildwindow will be centered in reference to the
parent MDI Form.

Now, the problems that I have met, while trying to implement this (at first
glance) trivial part of the program.

When my childwindow touches on of the sides of the main window it looks as
if the window is going to be docked left (doesn't matter which border I meet
left, right, top, bottom, only for 1px if I touch the border the window pulls
to left and resizes it's height as if it is going to be docked. When I pull
the window further over the border, the visualisation is ok.

That's the first part of the problem. The second one is the following.
With the center on screen menu item comes a bit of code in frmMain looking
like this:
Dim parentWidth As Integer = Me.Size.Width
Dim parentHeight As Integer = Me.Size.Height
Dim childWidth As Integer = Me.ActiveMdiChild.Size.Width
Dim childHeight As Integer = Me.ActiveMdiChild.Size.Height
Me.ActiveMdiChild.Left = ((parentWidth - childWidth) / 2) +
Me.Location.X
Me.ActiveMdiChild.Top = ((parentHeight - childHeight) / 2) +
Me.Location.Y
Try removing the Me.Location.X and Me.Location.Y. They aren't necessary.
 
the thing is when i step trough the lines of code
@ Me.ActiveMdiChild.Left = ...value ...
If I step trough that line Me.ActiveMdiChild.Left Gets the value 0 even when
the value passed is 304 (for example)
the same with the Top Property

I have no clue as to why that happends :(
 
Back
Top