Jump to content
  • Advertisement
Sign in to follow this  
tom_mai78101

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

This topic is 2592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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.

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.])

Share this post


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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!