我的程序是这样开始的:

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

        mapEditor.Run();

        return 0;
    }

并且有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);
}

窗口永远不会开始最大化。为什么?

最佳答案

您将错误的第二个参数传递给ShowWindow。第二个参数应该是SW_...值,而不是WS_...值,如the documentation中所述。

关于c++ - 如何使WS_MAXIMIZE工作?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15845768/

10-11 22:08