View Full Version : Automatically Center a window in a viewport
5 Aug 2010, 10:26 PM
I may be missing a thing or two here, but is there a way to center a window inside a viewport? I have a login form and I don't want it to appear on the left hand side of the window. Layout absolute only allows me to position absolutely, but I want it to center automatically based on the user's screen res.
I just want to know if it is possible to do it with the designer itself.
Thanks a mil for everything up until now!
When is the new ver. coming out? hehehehe
6 Aug 2010, 7:09 AM
A window isn't really meant to be positioned within anything, as it is a floating element. So position doesn't matter. Or more precisely, position doesn't happen until you show() the window. Windows automatically are centered to the Viewport when they are shown, by default. So when you actually use your window in your implementation code, you'll see that it works as you want out of the box.
6 Aug 2010, 9:29 AM
I know all that hehehe! Thank you - but mine just seems to position itself inside the viewport on the top-left hand corner...
I mean I am using the designer. I add a simple window. The viewport is automatically as a "auto" layout. Now the window inside it shows on the left hand side when I export the project...!
6 Aug 2010, 10:22 AM
I see. Move the Window out to be a top-level component instead of inside of the Viewport. You can drag it from the Component Tree onto the edge of the Design canvas to move it out. :-)
6 Aug 2010, 11:10 PM
Hi...! Thank you for that! I have done what you said! It still does not seem to work! If you want to see go to http://www.valahian.co.za/dev/dotsimple/ and then click the logo to open the window with the login form.
Would you be kind to have a look at it and tell me what you think I am doing wrong?
7 Aug 2010, 7:38 AM
I have looked...nice loading screen :-) There is an x/y configured on the Window, which makes it show at a particular point on the screen. Remove those two configurations (click the "x" next to each one) and the Window will show itself in the center of the screen.
7 Aug 2010, 10:01 PM
Oh man I must be the dumbest person on earth hahahaha! (blush)
Thank you so much! I feel stupid hehehehehe
P.S. Thanks for the comment hehehe
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.