Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I do to have WS_MAXIMIZE working?

There is how my program begins:

   int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
    {
        MapEditor mapEditor;

        mapEditor.Run();

        return 0;
    }

and there is MapEditor():

MapEditor::MapEditor()
{
    /* Creates the window */
    WNDCLASSEX wClass;
    ZeroMemory(&wClass,sizeof(WNDCLASSEX));
    wClass.cbSize=sizeof(WNDCLASSEX);
    wClass.style=CS_HREDRAW|CS_VREDRAW;
    wClass.lpfnWndProc=WinProc;
    wClass.cbClsExtra=NULL;
    wClass.cbWndExtra=NULL;
    wClass.hInstance=GetModuleHandle(0);
    wClass.hIcon=NULL;
    wClass.hCursor=LoadCursor(NULL,IDC_ARROW);
    wClass.hbrBackground=(HBRUSH)COLOR_WINDOW;
    wClass.lpszMenuName=NULL;
    wClass.lpszClassName="Map Editor";
    wClass.hIconSm=NULL;

    if(!RegisterClassEx(&wClass))
    {
        int nResult=GetLastError();

        MessageBox(NULL,"Failed to register window class","Window Class Failed",MB_ICONERROR);
    }

    ME_HWnd=CreateWindowEx(NULL,
            "Map Editor",
            "Map Editor",
            WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | WS_VISIBLE,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            NULL,
            NULL,
            GetModuleHandle(0),
            this);

    if(!ME_HWnd)
    {
        int nResult=GetLastError();

        MessageBox(NULL,"Window class creation failed","Window Class Failed",MB_ICONERROR);
    }
    ShowWindow(ME_HWnd, WS_MAXIMIZE);
}

The window won't ever start maximized. Why?

like image 853
Mickael Bergeron Néron Avatar asked Apr 06 '13 00:04

Mickael Bergeron Néron


1 Answers

You are passing the wrong second parameter to ShowWindow. The second parameter is supposed to be a SW_... value, not a WS_... value, as explained in the documentation.

like image 167
Raymond Chen Avatar answered Nov 02 '22 09:11

Raymond Chen