Sign in to follow this  
tom_mai78101

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

Recommended Posts

tom_mai78101    693
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?

Share this post


Link to post
Share on other sites
mhagain    13430
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.

Share this post


Link to post
Share on other sites
tom_mai78101    693
[quote name='mhagain' timestamp='1305741111' post='4812635']
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.
[/quote]

Oh. I see then. I thought it's possible for me to reset my window sizes back to normal...

Share this post


Link to post
Share on other sites
jbadams    25713
Could you clearly describe what you're actually trying to [i]do[/i]?


[b]mhagain[/b] 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?

Share this post


Link to post
Share on other sites
tom_mai78101    693
[quote name='jbadams' timestamp='1305787033' post='4812896']
Could you clearly describe what you're actually trying to [i]do[/i]?


[b]mhagain[/b] 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?
[/quote]


[url="http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-do-i-restore-all-window-explorers-to-factory/be135c5d-d37b-e011-9b4b-68b599b31bf5"]This came from here.[/url]
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[/color]" after clicking "[color="#0000ff"]Computer[/color]" in the [color="#9932cc"]Start Menu[/color], just after installing [color="#ffa500"]a brand new Windows 7 OS [/color]on your [/color][color="#48d1cc"]computer[/color].])

Share this post


Link to post
Share on other sites
jbadams    25713
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 [url="http://msdn.microsoft.com/en-us/library/ms632679(v=vs.85).aspx"]description of applying CW_USEDEFAULT to a Window's width, here[/url] (emphasis mine):
[quote]
If [i]nWidth[/i] is CW_USEDEFAULT, the system selects a default width and height for the window; the [b]default width extends from the initial x-coordinate to the right edge of the screen[/b], and the [b]default height extends from the initial y-coordinate to the top of the icon area[/b]. CW_USEDEFAULT is valid only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, [i]nWidth[/i] and [i]nHeight[/i] 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.

Share this post


Link to post
Share on other sites
tom_mai78101    693
[quote name='jbadams' timestamp='1305943905' post='4813725']
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 [url="http://msdn.microsoft.com/en-us/library/ms632679(v=vs.85).aspx"]description of applying CW_USEDEFAULT to a Window's width, here[/url] (emphasis mine):
[quote]
If [i]nWidth[/i] is CW_USEDEFAULT, the system selects a default width and height for the window; the [b]default width extends from the initial x-coordinate to the right edge of the screen[/b], and the [b]default height extends from the initial y-coordinate to the top of the icon area[/b]. CW_USEDEFAULT is valid only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, [i]nWidth[/i] and [i]nHeight[/i] 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.
[/quote]

Thanks for the info.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this