Sign in to follow this  
Gondolin

[C++ Win32] WS_MAXIMIZE Unfunctional?

Recommended Posts

Gondolin    143
Using: Microsoft Visual C++ .NET 2003 7.1, Windows XP SP1 I'm writing a Win32 program in C++ in which the main window should initially be maximized. I have the window style set as WS_OVERLAPPEDWINDOW | WS_MAXIMIZE. This seems to work fine when I run the application from the Visual Studios Debugger (in both Debug and Release mode). However, when I open the application from its execute file the main window does not maximize. Why would opening the application from the Visual Studios Debugger recognize the WS_MAXIMIZE style and a manual execution not? (I've worked arround the problem by forcing the maximize with ShowWindow() and SM_MAXIMIZE, but this solution is rather unattractive.)

Share this post


Link to post
Share on other sites
Mike2343    1202
Try the WS_VISIBLE option also but really WS_MAXIMIZE, from my understanding, just calls ShowWindow internally. Remember debug and release do have slightly different behaviors from each other.

Some more info on WS_MAXIMIZE, etc. I came across:
MSDN Link

If not post the source and we'll go from there.

Share this post


Link to post
Share on other sites
xeddiex    238
I tried replicating the problem and, indeed, it does not work like you described - strange. Currently, the only thing I can think of is that the properties for height and width in CreateWindow override WS_MAXIMIZE. But that still doesn't explain why it only works in the IDE. I don't think ShowWindow is the problem also because removing it (with WS_OVERLAPPEDWINDOW and WS_MAXIMIZE set) still produces the same results. I'll keep looking for a solution, while hopefully, in the meantime, someone will provide an explanation.

- xeddiex

Share this post


Link to post
Share on other sites
Gondolin    143
I've found something that might be irrelevant, but in the MSDN reference library there are two explanations for the WS_MAXIMIZE style. Under the normal reference library it is listed as:

WS_MAXIMIZE
Creates a window that is initially maximized.

...under the MFC reference library (which lists everything exactly the same as the normal reference library, except for this WS_MAXIMIZE):

WS_MAXIMIZE Creates a window of maximum size.

It could have been a typo on their part, but its odd that the problem exists exactly between the difference of these two definitions (atleast in my case the window is not maximized but of maximum size when opened outside the IDE).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
the problem is that WS_MAXIMIZE apparently does not apply when using WS_OVERLAPPEDWINDOW. if you replace WS_OVERLAPPEDWINDOW with WS_POPUP you will get a maximized window. of course this may not apply to all versions of Windows, or even all versions of the Windows shell UI for that matter.

WS_OVERLAPPEDWINDOW is MS's old default window "type" and they apparently coded CreateWindow/Ex to ignore certain styles, thinking that ShowWindow would be called with SW_SHOWDEFAULT, which causes the window to be displayed according to the CreateProcess startup info parms. this ultimately gives the user the control of how an app's main window would be displayed by using the shell's shortcut settings.

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