# Thread: Center Window inside another Window?

1. ## Center Window inside another Window?

I can calculate how to center a window on the desktop screen.

But I'm not able to center a window inside another window! That's because the Window can be in any position on the Screen.

Does anyone know the calculation to do that?

2. > Does anyone know the calculation to do that?
Pencil, paper - and a bit of geometry.

> I can calculate how to center a window on the desktop screen.
Try doing the same, but introduce a left=0 and top=0 into the terms.

3. Originally Posted by Salem
>
> I can calculate how to center a window on the desktop screen.
Try doing the same, but introduce a left=0 and top=0 into the terms.
Left and Top are already zero. I already do that to calculate the Desktop Center!
I calculate based on the Desktop Screen Size, but the Desktop screen does not change its x,y position.

I need to know how to calculate from the Center of the x,y position where the main window is! that is not ZERO
And the main window isn't in the center of the desktop, it could be anywhere. And it's exactly this x, y of this Window that I have no idea where to put in this calculation!
Soon I didn't understand what you wanted to explain!

4. Originally Posted by Salem
> Try doing the same, but introduce a left=0 and top=0 into the terms.
Thanks for trying to help, but this calculation you didn't know how to do! left and top could never be ZERO because the main window would never be in this position!

I managed to solve the problem because I found where I should put the position of the main window that I had no idea where to put in the calculation, it was by trying and error!

5. Ask yourself: "What is the origin for a 'child' window?" Is it the "desktop" or its parent window? And what if you have multiple monitors?

6. Originally Posted by flp1969
Ask yourself: "What is the origin for a 'child' window?" Is it the "desktop" or its parent window? And what if you have multiple monitors?
I understand your point. But this is a warning window! And it needs to be shown on top of the Window that called it!

So even if you have multiple monitors, it will only be displayed on the monitor where the Window that called you is!

But don't worry, I already solved the problem!
Thanks!