PDA

View Full Version : Center Window ?



octane6228
02-04-2004, 04:15 PM
Does anybody know how to center a window on the screen ? Even if the users screen is at different resolutions ??

Thanks for any help

Corey
02-04-2004, 04:30 PM
Hi. This is real easy, check out the attached example. Code is on page OnShow event and on the label's OnClick event. Hope that helps. :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Stefan_M
02-04-2004, 11:24 PM
Please don't forget there are some people using double monitor systems.
It looks very bad if you center the window on the screen.
One halfe is on the left monitor and the other on the right.

Stefan

Corey
02-04-2004, 11:42 PM
Hi Stefan, good point, but I'm pretty sure with dual monitors your computer treats it as 2 screens, not one. So it should still work fine. Or at least I know that the old 4.0 window move action worked perfectly on my ex-Matrox with dual monitors running...

FWIW it seems to me that the way it works is that the computer will center the window on the active screen for that window, i.e. left or right, and in the case that you have your window sitting halfway on each (which is way too rare to worry about anyhow) it choose the left screen. Or at least that's my recollection.

Please let us know if you ever see it act otherwise somewhere. :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Stefan_M
02-04-2004, 11:55 PM
Hi, Corey,

this doesn' work for me.
My screen resolution is 2560 * 1024 pixel on a matrox millennium G450 Dual Head.

You are right, on NT4.0 there are two separate screens but on win2000 there is one great screen over two monitors.

Corey
02-05-2004, 01:31 AM
Hi. Odd.

Anyhow FWIW this scenario is so rare that it's not worth planning for. This is a scenario which will occur in less than .001% of users basically, and it's a guarantee that anyone in this scenario is a tech minded individual who will be aware of the anomaly and how to get around it if need be. Or at least that's my opinion on it anyhow, I doubt you'll ever run into a end user at 2560 X 1024... :)

Nonetheless it might would be easy to detect this using one extra action, i.e. just check if your screen width is more than 2.4 times your screen height, if it is, you are facing this scenario...

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

octane6228
02-05-2004, 07:46 AM
Thanks everyone for you help, but I wanted this to work when my project started up....I tried the code in the Project's, Actions, Startup........But an error occurs.

Any ideas on how to get the window to automatically center on starup of the app ????

Thanks again.

Stefan_M
02-05-2004, 02:15 PM
try this demo

stefan