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"
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
UNUSED(hPrevInstance);
UNUSED(pCmdLine);
UNUSED(nCmdShow);
if (AllocConsole()) {
FILE *f;
freopen_s(&f, "CONOUT$", "w", stdout);
@@ -42,8 +49,8 @@ int WINAPI ci2_wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmd
HWND hwnd = CreateWindowExW(
0,
CLASS_NAME,
L"My -mwindows App",
"Win32 Window Class",
L"Win32 CI2 App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 200,
NULL, NULL, hInstance, NULL
@@ -63,19 +70,19 @@ int WINAPI ci2_wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmd
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.
wprintf(L"Console present. argc=%d\n", argc);
UNUSED(wargv);
HINSTANCE hInst = GetModuleHandleW(NULL);
WNDCLASSW wc = {0};
wc.lpfnWndProc = WndProc;
wc.hInstance = hInst;
wc.lpszClassName = L"MyWinClass";
wc.lpszClassName = L"Win32 Window Class";
RegisterClassW(&wc);
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,
NULL, NULL, hInst, NULL);
ShowWindow(hwnd, SW_SHOW);