CreateWindow and WS_MAXIMIZE problems

I have a very strange problem. Don't know if it is I who is doing something wrong, or something else is the matter.

I create a new window for our program with the following command:

CreateWindow(_T("TEST"), title, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE , x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);

Now when I start the program from the command line, the window is shown maximized. However when I execute the binary from windows (double clicking the program) it is *NOT* maximized but shown with at a resolution of WxH The window is not full-screen, just a simple canvas. How is this even possible

I have double-checked every parameter passed to CreateWindow, even had the program crash right after a call to this function to make sure nothing changes the window size and it still happens.

What is going on here I am using VS2005 Express.



Answer this question

CreateWindow and WS_MAXIMIZE problems

  • jmodares.com

    I am going to reply to myself. I have made a very simple example application; see full source-code below. When I double-click the binary the window is NOT maximized when I run it from the command prompt it is!

    #include <windows.h>
    #include <tchar.h>
    
    LRESULT CALLBACK MessageProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
     switch (uMsg) {
     case WM_DESTROY: PostQuitMessage(WM_QUIT); return 0;
     }
     return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
     MSG Msg;
     HWND hWnd;
     WNDCLASS WndCls;
    
     WndCls.style     = CS_HREDRAW | CS_VREDRAW;
     WndCls.lpfnWndProc  = MessageProcedure;
     WndCls.cbClsExtra  = 0;
     WndCls.cbWndExtra  = 0;
     WndCls.hInstance   = hInstance;
     WndCls.hIcon     = NULL;
     WndCls.hCursor    = NULL;
     WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
     WndCls.lpszMenuName = NULL;
     WndCls.lpszClassName = _T("SAMPLEAPP");
    
     RegisterClass(&WndCls);
     hWnd = CreateWindow(_T("SAMPLEAPP"), _T("something"), WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE,
               CW_USEDEFAULT, CW_USEDEFAULT, 400, 400, NULL, NULL, hInstance, NULL);
     
     if (!hWnd) return 0;
    
     while( GetMessage(&Msg, NULL, 0, 0) ) {
     TranslateMessage(&Msg);
     DispatchMessage(&Msg);
     }
    
     return 0;
    }
    

  • CreateWindow and WS_MAXIMIZE problems