Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 8 of 8

Thread: Center Window ?

  1. #1
    Join Date
    Feb 2004
    Posts
    47

    Lightbulb Center Window ?

    Does anybody know how to center a window on the screen ? Even if the users screen is at different resolutions ??

    Thanks for any help

  2. #2
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    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
    Attached Files

  3. #3
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    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

  4. #4
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    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

  5. #5
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    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.

  6. #6
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    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

  7. #7
    Join Date
    Feb 2004
    Posts
    47

    Grin Doesn't work on startup ?

    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.

  8. #8
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    try this demo

    stefan
    Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts