繼續上一篇,現在需要把控制臺隱藏,只顯示調用duiLib框架顯示的窗口。
右鍵項目 → 屬性 → 鏈接器 → 系統 → ?子系統?改為?窗口(/SUBSYSTEM:WINDOWS)。
原來是這樣:
修改為:
運行報錯:
需要修改入口函數為WinMain。如下示例:
#include <windows.h>LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {if (uMsg == WM_DESTROY) {PostQuitMessage(0);return 0;}return DefWindowProc(hwnd, uMsg, wParam, lParam);
}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {const wchar_t CLASS_NAME[] = L"MyWindowClass";WNDCLASS wc = {};wc.lpfnWndProc = WindowProc;wc.hInstance = hInstance;wc.lpszClassName = CLASS_NAME;RegisterClass(&wc);HWND hwnd = CreateWindowEx(0,CLASS_NAME,L"到底是天地會還是整人會啊",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,NULL, NULL, hInstance, NULL);ShowWindow(hwnd, nCmdShow);UpdateWindow(hwnd);MSG msg = {};while (GetMessage(&msg, NULL, 0, 0)) {TranslateMessage(&msg);DispatchMessage(&msg);}return 0;
}
運行:
ok.?