473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MDI Childwindows, center on screen problem

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
Dec 13 '05 #1
2 1540
I can only help with one item:

SL33PY wrote:
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.
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

Dec 13 '05 #2
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 :(

"tomb" wrote:
I can only help with one item:

SL33PY wrote:
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.
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

Dec 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ahmed Jewahar | last post by:
Hi All, I'm new to this forum as well as new to ASP.NET. My backgorund is ASP. But, I'm just doing my .NET course with MS Certified training center currently. I have couple of questions (it...
10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
8
by: Freek te Water | last post by:
Hi, Hope no-one is offended by my probably noob question... Context: I have a web page design, which always centres in the middle of the screen (using a 100%*100% HTML-table). Now I also use...
7
by: Alex | last post by:
Hi Everone, I need some advice on how to setup 4 columns where the outside two are absolute (120px) and the inner two (side by side) are relevent (Fluid) and change with the screen. Here's my...
11
by: Hoku | last post by:
I am using dual monitors on a dual head ATI AGP4x video card. I installed the Nov 11 2005 release of ATI's catalyst control center with Hydravision to manage the dual monitor setup. I recently...
3
by: jerry.ranch | last post by:
Hi I'm trying to figure out how to center forms on a page I have a form built with some tabbed pages, and I'm playing with the form properties, but it always displays top and left and not centered...
1
by: Lee99 | last post by:
Hey guys, Love the forum. Been browsing a lot, now time for my first post :-) I'm wondering how to set a <div> tag to be center aligned to the screen, both horizontally and vertically... so...
19
roula
by: roula | last post by:
I HATE DIVS AND DIFFERENT BROWSERS!!! i spent the whole day and night searching for a way to center align stupid divs, the problem is that the code is so sensitive, i lost my mind trying to make them...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.