We help IT Professionals succeed at work.

Windows Notepad.exe window pos

Kunt
Kunt asked
on
Medium Priority
561 Views
Last Modified: 2013-12-03
i made a clone of windows Notepad.exe
i cant figure out how it calculates its startup window pos.

i know the window width = the screen height
how does it calculate the size of the window height?

please can someone figure this out.
Comment
Watch Question

Commented:
The last invoked position information is stored in the registry.

What exactly is the problem?

Author

Commented:
nope

Commented:
>> nope

"nope" what?

HKCU\Software\Microsoft\Notepad\iWindowPosY
HKCU\Software\Microsoft\Notepad\iWindowPosX
HKCU\Software\Microsoft\Notepad\iWindowPosDX
HKCU\Software\Microsoft\Notepad\iWindowPosDY

Author

Commented:
what version do u have?

im using WinME and it doesnt have those reg keys

Commented:
>> what version do u have?

Win2K

>> im using WinME and it doesnt have those reg keys

Could be...

Install Regmon from http://www.sysinternals.com/ntw2k/source/regmon.shtml and check what registry keys Notepad uses on your system.

Author

Commented:
i doesnt read the size from the registry, it calculates it somehow on the screen and is the same everytime

Commented:
If you resize and move the window, close it, then start another instance, where will the new window open?  If it will open with the last position/size (like it does on Win2K) it means that the size/position parameters were saved somewhere (and Microsoft prefers to use the registry for that).

Author

Commented:
it doesnt read the size from the registry, it calculates it somehow on the screen AND IS THE SAME EVERYTIME.

on WinME it doesnt use the last window pos.
Commented:
Just checked it - same behaviour under Win98.

Guess what?  Notepad does not calculate its window size/position at all, it let's the system position it.
Commented:
Size x and y
Position x and y
for CreateWindowEx

is the same for all 4 arguments

#define CW_USEDEFAULT     0x80000000

which mean system default.


Good luck Kunt.

Author

Commented:
yeh i use CW_USEDEFAULT in C++ and thats fine, but i need to calculate it in VB, how does the system calculate it?

Author

Commented:
is there a function to set the window size that accepts CW_USEDEFAULT?

Commented:
Not to set the window size.
Only when creating a new window (Any type)

An application can allow Windows to calculate the initial size or position of a top-level window by specifying CW_USEDEFAULT in say CreateWindowEx. If the application sets the window's coordinates to CW_USEDEFAULT and has created no other top-level windows, Windows sets the new window's position relative to the upper left corner of the screen; otherwise, it sets the position relative to the position of the top-level window that the application created most recently. If the width and height parameters are set to CW_USEDEFAULT, Windows calculates the size of the new window. If the application has created other top-level windows, Windows bases the size of the new window on the size of the application's most recently created top-level window. Specifying CW_USEDEFAULT when creating a child or pop-up window causes Windows to set the window's size to the default minimum window size.

Commented:
Straight from winuser.h:
#define CW_USEDEFAULT ((int)0x80000000)

Just use the numeric constant in your VB program.

Commented:
split?