What is the algorithm used to pass a CW_USEDEFAULT and get a nice size in Win32?

Started by
5 comments, last by tom_mai78101 12 years, 11 months ago
In the CreateWindow() and CreateWindowEx(), when we pass a parameter CW_USEDEFAULT to it, it does an algorithm that sets the size of the window to a specific size.

The size also depends on the screen resolution. For 1280x1024, I get a width and height of 640x480, respectively. I get an offset of 32x16 from the upper left corner of the monitor.

Is this predetemined? Or this is something that relies on a specific algorithm to calculate this out?
Advertisement
It doesn't seem to be documented, which generally tends to mean that it's an internal implementation detail, subject to change from version to version, and shouldn't be relied on.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


It doesn't seem to be documented, which generally tends to mean that it's an internal implementation detail, subject to change from version to version, and shouldn't be relied on.


Oh. I see then. I thought it's possible for me to reset my window sizes back to normal...
Could you clearly describe what you're actually trying to do?


mhagain is correct that you shouldn't rely on implementation details, but if you tell us what you're actually trying to achieve we may be able to recommend a solution.

My guess is that you might be wondering how to restore the previous desktop resolution after going to full screen and changing the settings?

- Jason Astle-Adams


Could you clearly describe what you're actually trying to do?


mhagain is correct that you shouldn't rely on implementation details, but if you tell us what you're actually trying to achieve we may be able to recommend a solution.

My guess is that you might be wondering how to restore the previous desktop resolution after going to full screen and changing the settings?



This came from here.
It has nothing to do with programming or whatsoever. I'm just trying to fiddle with Windows 7 to try to get the factory presetted window size (trying to obtain the original width and height of the modeless window, in other words, I'm trying to get the window size of [[color="#ff0000"]"[color="#0000ff"]My Computer" after clicking "[color="#0000ff"]Computer" in the [color="#9932cc"]Start Menu, just after installing [color="#ffa500"]a brand new Windows 7 OS on your [color="#48d1cc"]computer.])
The user asking that question has misunderstood what CW_USEDEFAULT actually does -- (s)he wants to restore the original default Window size/position from a clean installation of Windows, which is not the intended purpose of CW_USEDEFAULT. See the description of applying CW_USEDEFAULT to a Window's width, here (emphasis mine):

If nWidth is CW_USEDEFAULT, the system selects a default width and height for the window; the default width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial y-coordinate to the top of the icon area. CW_USEDEFAULT is valid only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, nWidth and nHeight are set to zero.
[/quote]

I'm not personally aware of a way to achieve what that person was after, and as it doesn't interest me I'm not going to research it -- you'll need to jump on Google or your favourite search engine and do more poking around if you want to answer the question.

- Jason Astle-Adams


The user asking that question has misunderstood what CW_USEDEFAULT actually does -- (s)he wants to restore the original default Window size/position from a clean installation of Windows, which is not the intended purpose of CW_USEDEFAULT. See the description of applying CW_USEDEFAULT to a Window's width, here (emphasis mine):

If nWidth is CW_USEDEFAULT, the system selects a default width and height for the window; the default width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial y-coordinate to the top of the icon area. CW_USEDEFAULT is valid only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, nWidth and nHeight are set to zero.


I'm not personally aware of a way to achieve what that person was after, and as it doesn't interest me I'm not going to research it -- you'll need to jump on Google or your favourite search engine and do more poking around if you want to answer the question.
[/quote]

Thanks for the info.

This topic is closed to new replies.

Advertisement