bool WinInit (void) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = AppInstance (); wcex.hIcon = NULL; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = APP_TITLE; wcex.hIconSm = NULL; if (!RegisterClassEx(&wcex)) { WinPopup ("Cannot create window class"); return false; } if (!(hwnd = CreateWindowEx (0, APP_TITLE, APP_TITLE, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, 0, 544, 640, NULL, NULL, AppInstance (), NULL))) { WinPopup ("Cannot create window"); return false; } ShowWindow (hwnd, SW_SHOW); UpdateWindow (hwnd); return true; }
bool WinInit (void) { WNDCLASSEX wcex; int x, y; int style; bool max; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)ScreenSaverProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = instance; wcex.hIcon = NULL; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = APP_TITLE; wcex.hIconSm = NULL; if (!RegisterClassEx(&wcex)) { WinPopup ("Cannot create window class"); return false; } x = IniInt ("WindowX"); y = IniInt ("WindowY"); style = WS_TILEDWINDOW; style |= WS_MAXIMIZE; width = IniInt ("WindowWidth"); height = IniInt ("WindowHeight"); width = CLAMP (width, 800, 2048); height = CLAMP (height, 600, 2048); half_width = width / 2; half_height = height / 2; max = IniInt ("WindowMaximized") == 1; if (!(hwnd = CreateWindowEx (0, APP_TITLE, APP_TITLE, style, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, instance, NULL))) { WinPopup ("Cannot create window"); return false; } if (max) ShowWindow (hwnd, SW_MAXIMIZE); else ShowWindow (hwnd, SW_SHOW); UpdateWindow (hwnd); return true; }