1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows Is window positioning retained by OS or application?

Discussion in 'Software' started by boiled_elephant, 15 Feb 2012.

  1. boiled_elephant

    boiled_elephant Merom Celeron 4 lyfe

    Joined:
    14 Jul 2004
    Posts:
    6,914
    Likes Received:
    1,196
    A lot of programs retain their size and position settings when relaunched, which can be a problem if you have a secondary monitor and don't always turn it on - you launch programs and simply can't find them, until you realise what's happened.

    I keep a list of applets I'd like to make if I ever successfully get into programming, and one that would be handy is a script to reset the positioning of windows currently located on the secondary monitor. Obviously, this would only be possible if the position settings are OS-controlled and not retained individually by the programs.

    Anyone know which is the case?
     
  2. Pookeyhead

    Pookeyhead It's big, and it's clever.

    Joined:
    30 Jan 2004
    Posts:
    10,961
    Likes Received:
    561
    I seem to recall this is OS controlled.

    "you launch programs and simply can't find them, until you realise what's happened."


    Every damned day!... every day!.

    Write it, and I'd buy it.
     
  3. GoodBytes

    GoodBytes How many wifi's does it have?

    Joined:
    20 Jan 2007
    Posts:
    12,300
    Likes Received:
    710
    Window position of programs is managed by the PROGRAM itself.

    An onQuit event is set to the program, which when detected, it will store in it's settings the current location of itself. That is why, if you move a program window, and kill it (end task), the position would not be retained, as Windows force kill the program, so it can't execute it's onQuit event, and close properly. Such event is also used by many software to detect is a document or project needs to be saved before closing. Basically it looks into it's own variables if the project was modified, and prompt you if you want to save it, and then it quits itself.

    When you start a program, the program has 2 things it can do:
    -> Specify the position (so settings are loaded, gets the last position and set to)
    -> Doesn't specify anything, and it sets the window position to the top left corner with some padding, like you open command prompt in Windows. So Windows itself manages it.

    The problem is that the program that you are using, isn't checking what is your desktop size (Windows has API codes to get that info). So it doesn't know if the program position is out of your screen. What i do on my software, is that center it at first run, save the position on quit, and when you load it, it checks that if the position of the window is out of your desktop size, it will repositioned it at the center. If there is no problem, than it sets the position, so it appears correctly on your screen.

    Program window size is the same story.
     
    boiled_elephant likes this.
  4. Flibblebot

    Flibblebot Smile with me

    Joined:
    19 Apr 2005
    Posts:
    4,829
    Likes Received:
    297
    But if you have dual monitor and don't turn it on, does Windows change the resolution, or does it still get reported as the combined width of both monitors?

    As for writing apps for little things that niggle, I've always said that the first person to write an email program that told you when you'd forgotten to include an attachment would be a squillionaire - and then Mozilla do it in Thunderbird and release it for free :doh:
     
  5. TheKrumpet

    TheKrumpet Once more, into the breach!

    Joined:
    18 Oct 2011
    Posts:
    406
    Likes Received:
    34
    This. If you want a window to open in the same place you have to manually program that in. Otherwise it'll just open at the default size & position. If the programmer didn't add bounds checking then it'll happily open outside of the usable area.
     
  6. boiled_elephant

    boiled_elephant Merom Celeron 4 lyfe

    Joined:
    14 Jul 2004
    Posts:
    6,914
    Likes Received:
    1,196
    Poo. Many thanks, GoodBytes, that was informative (if disappointing).
     

Share This Page