请问我这个拿C++的WinAPI编的程序为什么运行无效果?

请问我这个拿C++的WinAPI编的程序为什么运行无效果?一个没有控制台和窗口,什么都没有,没反应?

感谢各位大神了!!!

IDE:Visual Studio 2017

#include <Windows.h>
LRESULT CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            break;
    }
    return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    WNDCLASSEXW wcx;
    wcx.cbSize = sizeof(WNDCLASSEXW);
    wcx.style = CS_HREDRAW | CS_VREDRAW;
    wcx.cbClsExtra = 0;
    wcx.cbWndExtra = 0;
    wcx.hInstance = hInstance;
    wcx.hIcon = NULL;
    wcx.hCursor = LoadCursor(NULL,IDC_ARROW);
    wcx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wcx.lpszMenuName = NULL;
    wcx.lpfnWndProc = WinProc;
    ATOM win = RegisterClassExW(&wcx);
    HWND hWnd;
    hWnd = CreateWindowW(L"MainWinClass", L"PMDG737-800模拟仓控制终端", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUPWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, (HWND)NULL, (HMENU)NULL, hInstance, (LPVOID)NULL);
    if (!hWnd) {
        MessageBoxW(NULL, L"窗口创建失败!", L"错误", 0);
        return 0;
    }
    ShowWindow(hWnd,SW_SHOW);
    UpdateWindow(hWnd);
    MSG msg;
    while (GetMessage(&msg,NULL,NULL,NULL)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
你说我会不会在Visual Studio 2017中哪里配置错了?

1个回答

看下编译器的选项,项目类型,加上/console没有

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐