The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ratch on November 16, 2005, 06:40:39 PM

Title: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 16, 2005, 06:40:39 PM
To the Ineffable All,
     I can't seem to get WS_MAXIMIZE or WS_MINIMIZE to work when I use it for the CreateWindow API. It appears these window style parameters are ignored.  Can anybody shed some liight on this prob.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: PBrennick on November 16, 2005, 08:32:49 PM
Ratch,
Try WS_OVERLAPPEDWINDOW

It will set the following attributes:

Quote
WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU OR WS_THICKFRAME OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX

Notice WS_MINIMIZEBOX OR WS_MAXIMIZEBOX, anyway that is how it is set in windows.inc and is what I use.

Paul
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 16, 2005, 08:59:25 PM
PBrennick,
     I do use WS_OVERLAPPEDWINDOW, and I do get all the size boxes, but that is not my problem.  I want the window to initially show at the max size upon program startup. WM_MAXSIZE is supposed to make that happen, but it doesn't.   Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 16, 2005, 09:25:54 PM
Are you calling ShowWindow after the creation of the window?
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 16, 2005, 09:31:36 PM
QvasiModo,
Quote
Are you calling ShowWindow after the creation of the window?

     Certainly, otherwise I would not see a window at all.  My problem is not that I don't see a window; it is that I don't see it initially maximized. Why not try it yourself and see if you can get a window initially maximized.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: hutch-- on November 17, 2005, 08:27:29 AM
Ratch,

When I need a maximised window, I use ShowWindow() with the SW_SHOWMAXIMIZED flag.


    push SW_SHOWMAXIMIZED
    push hWnd
    call ShowWindow


It has always worked fine
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: PBrennick on November 17, 2005, 10:17:19 AM
Quote
I want the window to initially show at the max size upon program startup.

It would have been helpful if you had said that in the initial post.

Paul
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 17, 2005, 02:46:46 PM
Hutch,
     Your SW_SHOWMAXIMIZED solution certainly works.  Still, according to the documentation, WS_MAXIMIZE is supposed to work also. Ratch

PBrennick,
     Doesn't CreateWindow imply a startup condition? Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 17, 2005, 04:36:29 PM
Quote from: Ratch on November 16, 2005, 09:31:36 PM
QvasiModo,
Quote
Are you calling ShowWindow after the creation of the window?

     Certainly, otherwise I would not see a window at all.  My problem is not that I don't see a window; it is that I don't see it initially maximized. Why not try it yourself and see if you can get a window initially maximized.  Ratch

It's still strange, because you shouldn't really need to call ShowWindow after window creation. Perhaps you were passing it a SW_DEFAULT or SW_SHOWNORMAL value and that was overriding whatever window styles you were using.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: G`HOST on November 17, 2005, 05:49:22 PM
Quote from: QvasiModo on November 17, 2005, 04:36:29 PM
, because you shouldn't really need to call ShowWindow after window creation. 
Well we do need to call showWindow to make it display on the screen ,or we dont ???

Quote from: QvasiModo on November 17, 2005, 04:36:29 PM
Perhaps you were passing it a SW_DEFAULT or SW_SHOWNORMAL value and that was overriding whatever window styles you were using.
Ya i think the same .if u pass the default window size in the createWindow call and then call ShowWindow with nCmdShow set to SW_SHOWDEFAULT or  SW_SHOWNORMAL then u wont get a maximized window.
But one question arises if we cant display our window without showWindow call and nCmdShow in it overrides the WS_MAXIMIZE in createWindow call then why the hell these flags(WS_MAXIMIZE or WS_MINIMIZE) are ment for.And if, only if we can display the window without calling ShowWindow(Which i doubt) then what should we put in " x,y,height,weidth "section of the CreateWindow call if Style==WS_MAXIMIZE??
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 17, 2005, 10:55:10 PM
G`HOST,
     Yes, ShowWindow with SW_MAXIMIZE does work, but it is a workaround.  One should be able to specify a max window in CreateWindow.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 18, 2005, 12:02:28 AM
Ratch,
WM_MAXIMIZE works only when size related parameters are set to:

x = CW_USEDEFAULT
y = SW_MAXIMIZE
nWidth = CW_USEDEFAULT
nHeigh = SW_MAXIMIZE


G`HOST,
Actually we don't. Window displays just fine if WM_VISIBLE flag is specified. ShowWindow is not required.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 18, 2005, 12:35:12 AM
arafel,
Quote
WM_MAXIMIZE works only when size related parameters are set to:

x = CW_USEDEFAULT
y = SW_MAXIMIZE
nWidth = CW_USEDEFAULT
nHeigh = SW_MAXIMIZE


     You really meant WS_MAXIMIZE, didn't you?  Anyhow, I doubt it.  WS_MAXIMIZE is a STYLE param, and not to be used to specify position and size of a window.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 18, 2005, 12:55:27 AM
Oh, yes i meant WS_MAXIMIZE.

And i didn't say to use it instead of the size parameters. This what i was talking about:

invoke   CreateWindowEx, 0, ADDR my_class, 0, WS_VISIBLE or WS_MAXIMIZE or WS_SYSMENU, CW_USEDEFAULT, SW_MAXIMIZE, CW_USEDEFAULT, SW_MAXIMIZE, 0, 0, hInstance, 0

works fine for me (providing there is no ShowWindow after it, which could override the current window display mode)
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: tenkey on November 18, 2005, 12:58:22 AM
Under certain conditions, the first window created will ignore WS_MAXIMIZE and WS_MINIMIZE. Instead, it will use the wShowWindow setting in the STARTUPINFO structure used by CreateProcess. This is known behavior for NT and Win95, and it was documented in the SDKs for those platforms. Haven't checked if this still happens on the newer OS's. Calling ShowWindow after creating the window will override that behavior - the first ShowWindow wasn't supposed to override the behavior.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 18, 2005, 06:11:21 AM
arafel,
     WM_MAXIMIZE is equated to 3.  Putting a 3 into the vertical position and the window height parameters of the CreateWindow call seems like a strange way to get the window to maximize initially.  I will have to try it.  Ratch

tenkey,
     You might be onto something.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 18, 2005, 06:31:22 AM
Ratch,

It works, trust me  :toothy

Here something i just found in the sdk documentation:

QuoteWindows can set the initial size and position for overlapped windows. To have Windows set the window's initial position, an application uses CW_USEDEFAULT for the X parameter to CreateWindow or CreateWindowEx. When an application uses CW_USEDEFAULT to set an overlapped window's position and uses the WS_VISIBLE style to have the window visible when it is created, Windows passes the Y parameter of CreateWindow or CreateWindowEx to ShowWindow. Thus, when an application uses CW_USEDEFAULT for the X parameter to CreateWindow or CreateWindowEx, the Y parameter must be one of the following:

SW_HIDE
SW_SHOWNORMAL
SW_NORMAL
SW_SHOWMINIMIZED
SW_SHOWMAXIMIZED
SW_MAXIMIZE
SW_SHOWNOACTIVATE
SW_SHOW
SW_MINIMIZE
SW_SHOWMINNOACTIVE
SW_SHOWNA
SW_RESTORE
Usually an application should use SW_SHOW for the Y parameter because SW_SHOW allows the proper functioning for WS_MAXIMIZE and WS_MINIMIZE styles.

To have Windows set the window's initial size, an application uses CW_USEDEFAULT for the nWidth parameter to CreateWindow or CreateWindowEx. When an application uses CW_USEDEFAULT to have Windows set the window's initial size, the nHeight parameter to CreateWindow or CreateWindowEx is ignored.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: MichaelW on November 18, 2005, 06:55:24 AM
For the CreateWindowEx API WS_MINIMIZE and WS_MAXIMIZE seem to work just as they should. Neither was affected by any of the class styles and extended window styles that I tested, or by SW_SHOWDEFAULT or SW_SHOWNORMAL, or by any but the most oddball window styles that I tested.

For the "CreateWindow" API, I don't know because the functions are not present in the user32.dll on my Windows 2000 system.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
        hInst     dd          0
        hWnd      dd          0
        wc        WNDCLASSEX  <>
        msg       MSG         <>
        className db          "minimal_test"
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    mov   hInst, rv(GetModuleHandle, NULL)
    mov   wc.cbSize,        sizeof WNDCLASSEX
    ;CS_HREDRAW
    ;CS_VREDRAW
    ;CS_NOCLOSE
    ;CS_BYTEALIGNWINDOW
    mov   wc.style,         CS_HREDRAW or CS_VREDRAW \
                              or CS_BYTEALIGNWINDOW
    mov   wc.lpfnWndProc,   OFFSET WndProc
    mov   wc.cbClsExtra,    NULL
    mov   wc.cbWndExtra,    NULL
    m2m   wc.hInstance,     hInst
    mov   wc.hbrBackground, COLOR_BTNFACE+1
    mov   wc.lpszMenuName,  NULL
    mov   wc.lpszClassName, OFFSET className
    mov   wc.hIcon,         NULL
    mov   wc.hCursor,       NULL
    mov   wc.hIconSm,       0
    invoke RegisterClassEx, ADDR wc
    ;WS_EX_OVERLAPPEDWINDOW
    ;WS_EX_DLGMODALFRAME
    ;WS_EX_TOOLWINDOW
    ;WS_EX_PALETTEWINDOW
    ;WS_OVERLAPPEDWINDOW
    ;WS_MINIMIZE
    ;WS_MAXIMIZE
    ;WS_DISABLED
    ;WS_POPUP
    ;WS_VISIBLE
    invoke CreateWindowEx,  WS_EX_OVERLAPPEDWINDOW,
                            ADDR className,
                            chr$("Test"),
                            WS_OVERLAPPEDWINDOW or WS_MAXIMIZE,
                            0,0,400,300,
                            NULL, NULL,
                            hInst, NULL
    mov   hWnd, eax
    ;SW_SHOWDEFAULT
    ;SW_SHOWNORMAL
    invoke ShowWindow, hWnd, SW_SHOWNORMAL
    invoke UpdateWindow, hWnd
  msgLoop:
    invoke GetMessage, ADDR msg, NULL, 0, 0
    .IF (eax != 0)
        invoke TranslateMessage, ADDR msg
        invoke DispatchMessage, ADDR msg
        jmp   msgLoop
    .ENDIF
    exit msg.wParam
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
    .IF (uMsg == WM_DESTROY)
        invoke PostQuitMessage, NULL
        return 0
    .ENDIF
    invoke DefWindowProc, hWin, uMsg, wParam, lParam
    ret
WndProc endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start

Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 18, 2005, 02:38:29 PM
MichaelW,
     Copied your code into my test bed, then assembled and linked it.  I get a window that initially shows a 400x300 pixel size on my WinXP box.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: Ratch on November 18, 2005, 02:42:54 PM
arafel,
Quote
Here something i just found in the sdk documentation: .....

     Whew! No wonder MS has trouble keeping consistancy across OSes.  Ratch
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: PBrennick on November 18, 2005, 04:08:23 PM
Ratch,
Michael's version did not maximize on my machine, either.  It does if I do this...


;
include \masm32\include\masm32rt.inc
;
.data
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hInst       dd  0
hWnd        dd  0
wc   WNDCLASSEX <>
msg         MSG <>
className   db  "minimal_test"
;
.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
    mov     hInst, rv(GetModuleHandle, NULL)
    mov     wc.cbSize, sizeof WNDCLASSEX
    mov     wc.style, CS_HREDRAW or CS_VREDRAW \
                      or CS_BYTEALIGNWINDOW
    mov     wc.lpfnWndProc, OFFSET WndProc
    mov     wc.cbClsExtra, NULL
    mov     wc.cbWndExtra, NULL
    m2m     wc.hInstance, hInst
    mov     wc.hbrBackground, COLOR_BTNFACE+1
    mov     wc.lpszMenuName, NULL
    mov     wc.lpszClassName, OFFSET className
    mov     wc.hIcon, NULL
    mov     wc.hCursor, NULL
    mov     wc.hIconSm, 0
    invoke  RegisterClassEx, ADDR wc
    invoke  CreateWindowEx, WS_EX_OVERLAPPEDWINDOW,
                            ADDR className, chr$("Test"),
                            WS_OVERLAPPEDWINDOW,
                            0, 0, 400, 300, NULL, NULL, hInst, NULL
    mov     hWnd, eax
    invoke  ShowWindow, hWnd, SW_SHOWMAXIMIZED  ; SW_SHOWNORMAL
    invoke  UpdateWindow, hWnd
msgLoop:
    invoke  GetMessage, ADDR msg, NULL, 0, 0
    .if (eax != 0)
      invoke  TranslateMessage, ADDR msg
      invoke  DispatchMessage, ADDR msg
      jmp     msgLoop
    .endif
    exit    msg.wParam
;
;
WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    .if (uMsg == WM_DESTROY)
      invoke  PostQuitMessage, NULL
      return  0
    .endif
    invoke  DefWindowProc, hWin, uMsg, wParam, lParam
    ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc endp
;
;
    end     start


This will display as maximized and also shows that WS_OVERLAPPEDWINDOW is all that is needed by CreateWindowEx to create a window.

Quote
Whew! No wonder MS has trouble keeping consistancy across OSes

You hit the nail on the head with that comment.  Sometimes I just want to pull the hair out of my head!

I am using a plain jane copy of XP Home Edition. BTW.
Paul
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: MichaelW on November 18, 2005, 04:41:49 PM
I don't have an XP system to test on, but on my Windows 2000 system I did note that this combination of styles will cause the window to open up maximized and then shrink back to 400x300:

invoke CreateWindowEx,  WS_EX_OVERLAPPEDWINDOW,
                            ADDR className,
                            chr$("Test"),
                            WS_OVERLAPPEDWINDOW or WS_MAXIMIZE or WS_VISIBLE,
                            0,0,400,300,
                            NULL, NULL,
                            hInst, NULL


I find it surprising that XP behaves this way. I thought maintaining code compatibility was a major design point for Microsoft.

Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 18, 2005, 05:03:39 PM
This works like a charm. Tested on Win2k. I think some style flags must have been wrong, or maybe neither ShowWindow or UpdateWindow didn't need to be called...


.386
.model flat,stdcall
option casemap:none

include windows.inc
include kernel32.inc
include user32.inc
includelib kernel32.lib
includelib user32.lib

.data
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hInst       dd  0
hWnd        dd  0
wc   WNDCLASSEX <>
msg         MSG <>
className   db  "minimal_test"
windName db  "Test"

.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
    mov     hInst, eax
    mov     wc.cbSize, sizeof WNDCLASSEX
    mov     wc.style, CS_HREDRAW or CS_VREDRAW \
                      or CS_BYTEALIGNWINDOW
    mov     wc.lpfnWndProc, OFFSET WndProc
    mov     wc.cbClsExtra, NULL
    mov     wc.cbWndExtra, NULL
    mov     wc.hInstance, eax
    mov     wc.hbrBackground, COLOR_BTNFACE+1
    mov     wc.lpszMenuName, NULL
    mov     wc.lpszClassName, OFFSET className
    mov     wc.hIcon, NULL
    mov     wc.hCursor, NULL
    mov     wc.hIconSm, 0
    invoke  RegisterClassEx, ADDR wc
    invoke  CreateWindowEx, 0,
                            ADDR className, offset windName,
                            WS_OVERLAPPEDWINDOW or WS_MAXIMIZE or WS_MAXIMIZEBOX or WS_VISIBLE,
                            0, 0, 400, 300, NULL, NULL, hInst, NULL
    mov     hWnd, eax
;    invoke  ShowWindow, hWnd, SW_SHOWMAXIMIZED  ; SW_SHOWNORMAL
;    invoke  UpdateWindow, hWnd
msgLoop:
    invoke  GetMessage, ADDR msg, NULL, 0, 0
    .if (eax != 0)
      invoke  TranslateMessage, ADDR msg
      invoke  DispatchMessage, ADDR msg
      jmp     msgLoop
    .endif
    invoke ExitProcess,msg.wParam

WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    .if (uMsg == WM_DESTROY)
      invoke  PostQuitMessage, NULL
      xor eax,eax
      ret
    .endif
    invoke  DefWindowProc, hWin, uMsg, wParam, lParam
    ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc endp

    end     start
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 18, 2005, 07:47:40 PM
QvasiModo,
The code you posted fails to create maximized window on XP.

This one works on my xp sp2. Could someone verify that it works on 2k too?

.386
.model flat,stdcall
option casemap:none

include windows.inc
include kernel32.inc
include user32.inc
includelib kernel32.lib
includelib user32.lib


.data
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hInst       dd  0
hWnd        dd  0
wc   WNDCLASSEX <>
msg         MSG <>
className   db  "minimal_test"
windName db  "Test"

.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
    mov     hInst, eax
    mov     wc.cbSize, sizeof WNDCLASSEX
    mov     wc.style, CS_HREDRAW or CS_VREDRAW \
                      or CS_BYTEALIGNWINDOW
    mov     wc.lpfnWndProc, OFFSET WndProc
    mov     wc.cbClsExtra, NULL
    mov     wc.cbWndExtra, NULL
    mov     wc.hInstance, eax
    mov     wc.hbrBackground, COLOR_BTNFACE+1
    mov     wc.lpszMenuName, NULL
    mov     wc.lpszClassName, OFFSET className
    mov     wc.hIcon, NULL
    mov     wc.hCursor, NULL
    mov     wc.hIconSm, 0
    invoke  RegisterClassEx, ADDR wc

    invoke  CreateWindowEx, 0,
                            ADDR className, offset windName,
                            WS_VISIBLE or WS_MAXIMIZE,
                            CW_USEDEFAULT, SW_MAXIMIZE, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL
    mov     hWnd, eax

                                  ; works even without WS_MINIMIZE

   ; invoke  CreateWindowEx, 0,
   ;                         ADDR className, offset windName,
   ;                         WS_VISIBLE,
   ;                         CW_USEDEFAULT, SW_MAXIMIZE, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL
   ; mov     hWnd, eax


msgLoop:
    invoke  GetMessage, ADDR msg, NULL, 0, 0
    .if (eax != 0)
      invoke  TranslateMessage, ADDR msg
      invoke  DispatchMessage, ADDR msg
      jmp     msgLoop
    .endif
    invoke ExitProcess,msg.wParam

WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    .if (uMsg == WM_DESTROY)
      invoke  PostQuitMessage, NULL
      xor eax,eax
      ret
    .endif
    invoke  DefWindowProc, hWin, uMsg, wParam, lParam
    ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc endp

    end     start
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: PBrennick on November 18, 2005, 09:19:26 PM
Mine works on XP, also.

Paul
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 18, 2005, 10:08:38 PM
Quote from: arafel on November 18, 2005, 07:47:40 PM
QvasiModo,
The code you posted fails to create maximized window on XP.

That's very strange, it works on 2K and it should too. But I just tried it on an XP SP2 it doesn't. Maybe they broke something at MS? :eek

BTW, SW_MAXIMIZE should not be passed as a parameter to CreateWindowEx.

Just curious, what's your service pack number?
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 18, 2005, 10:37:21 PM
It seems other people had the same problem. No luck finding a solution other than just calling ShowWindow. I'll post if I find out anything...

http://www.gamedev.net/community/forums/topic.asp?topic_id=26653
http://wwia.org/sgroup/c_prog/36263/1/
http://igda.org/Forums/showthread.php?s=2f3526e6e13dcb48008833629e08556f&threadid=1951
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 18, 2005, 10:53:27 PM
Quote from: QvasiModo
Just curious, what's your service pack number?

sp2
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 18, 2005, 11:00:37 PM
Quote from: QvasiModo
BTW, SW_MAXIMIZE should not be passed as a parameter to CreateWindowEx.

do you mean the SW_MAXIMIZE i pass in y parameter?
i think CreateWindow expects it to be SW_MAXIMIZE if WS_MAXIMIZE specified as style and x parameter is CW_USEDEFAULT.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: MichaelW on November 19, 2005, 01:24:11 PM
arafel,

On my Windows 2000 SP4 system your code opens a maximized window with nothing in the title bar except "Test".
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 19, 2005, 02:07:53 PM
MichaelW, thanks for testing.

For simplicity I haven't include any other styles, so the titlebar appears empty.


P.S. i just tested it with various styles combinations and it sees to work fine.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 21, 2005, 04:07:54 PM
Quote from: arafel on November 18, 2005, 11:00:37 PM
Quote from: QvasiModo
BTW, SW_MAXIMIZE should not be passed as a parameter to CreateWindowEx.

do you mean the SW_MAXIMIZE i pass in y parameter?
i think CreateWindow expects it to be SW_MAXIMIZE if WS_MAXIMIZE specified as style and x parameter is CW_USEDEFAULT.

Well, it's not in MSDN. Did you try removing them?

I think CW_USEDEFAULT could be used for the x, y, nWidth and nHeight parameters. Here's a quote from MSDN:
Quote
x
    [in] Specifies the initial horizontal position of the window. For an overlapped or pop-up window, the x parameter is the initial x-coordinate of the window's upper-left corner, in screen coordinates. For a child window, x is the x-coordinate of the upper-left corner of the window relative to the upper-left corner of the parent window's client area. If x is set to CW_USEDEFAULT, the system selects the default position for the window's upper-left corner and ignores the y parameter. CW_USEDEFAULT is valid only for overlapped windows; if it is specified for a pop-up or child window, the x and y parameters are set to zero.

y
    [in] Specifies the initial vertical position of the window. For an overlapped or pop-up window, the y parameter is the initial y-coordinate of the window's upper-left corner, in screen coordinates. For a child window, y is the initial y-coordinate of the upper-left corner of the child window relative to the upper-left corner of the parent window's client area. For a list box y is the initial y-coordinate of the upper-left corner of the list box's client area relative to the upper-left corner of the parent window's client area. If an overlapped window is created with the WS_VISIBLE style bit set and the x parameter is set to CW_USEDEFAULT, the system ignores the y parameter.

nWidth
    [in] Specifies the width, in device units, of the window. For overlapped windows, nWidth is the window's width, in screen coordinates, or CW_USEDEFAULT. If nWidth is CW_USEDEFAULT, the system selects a default width and height for the window; the default width extends from the initial x-coordinates to the right edge of the screen; 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, the nWidth and nHeight parameter are set to zero.

nHeight
    [in] Specifies the height, in device units, of the window. For overlapped windows, nHeight is the window's height, in screen coordinates. If the nWidth parameter is set to CW_USEDEFAULT, the system ignores nHeight.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: arafel on November 21, 2005, 05:53:54 PM
Yes, but psdk also mentions in other place, that when specifying WS_VISIBLE style and CW_USEDEFAULT for x parameter, y parameter gets passed to ShowWindow by CreateWindow function (see the psdk quote I posted earlier).

I did tried removing them, with no luck.
The only way I got an initially maximized window on my machine (XP) is: WS_VISIBLE style, CW_USEDEFAULT for x and SW_MAXIMIZE for y.
Although it doesn't explain why WS_MAXIMIZE doesn't work by itself. It wors fine for creating initially minimized/maximized/whatever windows without calling ShowWindow after CreateWindow.
Title: Re: WS_MAXIMIZE AND WS_MINIMIZE
Post by: QvasiModo on November 21, 2005, 10:42:50 PM
Quote from: arafel on November 21, 2005, 05:53:54 PM
Yes, but psdk also mentions in other place, that when specifying WS_VISIBLE style and CW_USEDEFAULT for x parameter, y parameter gets passed to ShowWindow by CreateWindow function (see the psdk quote I posted earlier).

I did tried removing them, with no luck.
The only way I got an initially maximized window on my machine (XP) is: WS_VISIBLE style, CW_USEDEFAULT for x and SW_MAXIMIZE for y.

Ah, I see now, sorry :red

Quote
Although it doesn't explain why WS_MAXIMIZE doesn't work by itself. It wors fine for creating initially minimized/maximized/whatever windows without calling ShowWindow after CreateWindow.

Seems like a bug to me, or they broke compatibility with previous Windows versions for some reason... :naughty: