Win32 fix

This commit is contained in:
2026-05-12 13:53:20 -05:00
parent 4117bc5dd4
commit af802505ec

View File

@@ -22,8 +22,15 @@ SOFTWARE.
* --------------------------------------------------------------------------*/ * --------------------------------------------------------------------------*/
#include "../include/ci2.h" #include "../include/ci2.h"
int WINAPI ci2_wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) { int WINAPI ci2_wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PWSTR pCmdLine,
int nCmdShow) {
// Create a console so stdout/stderr work // Create a console so stdout/stderr work
UNUSED(hPrevInstance);
UNUSED(pCmdLine);
UNUSED(nCmdShow);
if (AllocConsole()) { if (AllocConsole()) {
FILE *f; FILE *f;
freopen_s(&f, "CONOUT$", "w", stdout); freopen_s(&f, "CONOUT$", "w", stdout);
@@ -42,8 +49,8 @@ int WINAPI ci2_wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmd
HWND hwnd = CreateWindowExW( HWND hwnd = CreateWindowExW(
0, 0,
CLASS_NAME, "Win32 Window Class",
L"My -mwindows App", L"Win32 CI2 App",
WS_OVERLAPPEDWINDOW, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 200, CW_USEDEFAULT, CW_USEDEFAULT, 400, 200,
NULL, NULL, hInstance, NULL NULL, NULL, hInstance, NULL
@@ -63,19 +70,19 @@ int WINAPI ci2_wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmd
return (int)msg.wParam; return (int)msg.wParam;
} }
int WINAPI ci2_wmain(int argc, wchar_t **argv) { int WINAPI ci2_wmain(int argc, ci2_sys_char *wargv[]) {
// You already have a console because this is a console subsystem binary. // You already have a console because this is a console subsystem binary.
wprintf(L"Console present. argc=%d\n", argc); wprintf(L"Console present. argc=%d\n", argc);
UNUSED(wargv);
HINSTANCE hInst = GetModuleHandleW(NULL); HINSTANCE hInst = GetModuleHandleW(NULL);
WNDCLASSW wc = {0}; WNDCLASSW wc = {0};
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.hInstance = hInst; wc.hInstance = hInst;
wc.lpszClassName = L"MyWinClass"; wc.lpszClassName = L"Win32 Window Class";
RegisterClassW(&wc); RegisterClassW(&wc);
HWND hwnd = CreateWindowExW( HWND hwnd = CreateWindowExW(
0, wc.lpszClassName, L"GUI from wmain", 0, wc.lpszClassName, L"Win32 CI2 App",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
NULL, NULL, hInst, NULL); NULL, NULL, hInst, NULL);
ShowWindow(hwnd, SW_SHOW); ShowWindow(hwnd, SW_SHOW);