14

Where is the information about the position of a window stored?

An example: I start notepad.exe, and it starts neither minimized or maximized, but just a medium size window in the center of the screen. If I close it and start it again, it is at the same XY coordinates. But then if I close it while it is at the bottom of the screen, it will start up again at the bottom (as opposed to the midlle) of the screen.

If I wanted to manually change the XY positions of a window so it were to open up at a non-standard location, what would I need to edit?

Probably the registry, but where?

1 Answer 1

10

Each program stores information about its windows in its own way. For Notepad, I found the following in my Windows XP registry.

In the registry, go to the following folder

HKEY_CURRENT_USER\Software\Microsoft\Notepad

then modify the following values

iWindowPosX
iWindowPosY
iWindowPosDX
iWindowPosDY

X and Y are the coordinates of the window's top left corner. DX and DY are the width and height of the window.

Other programs might save window position information in the registry or in other settings files.

5
  • So each program has to handle its own positioning data??
    – BenjiWiebe
    Jan 11, 2013 at 3:24
  • I was hoping that Windows handles it. But I got a brainwave. I compiled a very basic Win32 GUI program, and looked through the code to locate position setting code. All I found was a line that told Windows to position the program. Windows then positioned the program like any console program -- top left corner, then a little lower and to the right, and then lower again, until finally resetting it to the top left corner. Demo: type start 10 times into test.bat and run it.
    – BenjiWiebe
    Jan 11, 2013 at 3:32
  • I just saw that iWindowPosX was set to fffffffd (4294967293) in my case. Any idea how that massive number works?
    – Karan
    Jan 11, 2013 at 3:40
  • @BenjiWiebe They're different things: 1. If a program remembers a window's position so it can put it in the same place next time, then the program gets to choose how and where it saves the window coordinates and size. It could save the values in the registry, a text file, or some other way. 2. If you are writing a program that makes a window, you should be able to specify the window's position and size when you create the window. I guess if you don't specify them, Windows will choose a default placement like you describe. Perhaps you can get more specific guidance on a programming forum.
    – Bavi_H
    Jan 12, 2013 at 4:55
  • 2
    @Karan That number is -3 when the bits are treated as a signed value. Briefly: imagine an odometer with eight reels, and each reel has the digits 0 to 9 then A to F on it. If you start at 00000000 then click the odometer backwards three times, you end up at FFFFFFFD. For more detail: learn about binary, hexadecimal, and two's complement.
    – Bavi_H
    Jan 12, 2013 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .