23 #include "C4Version.h"
30 static int edittext_toi(HWND hWnd,
int field)
32 WCHAR buf[512]; buf[511] = 0;
33 GetDlgItemTextW(hWnd,field,buf,509);
35 const char* bufp = data.getData();
36 while(*bufp ==
' ') ++bufp;
37 int res = strtol(bufp,
nullptr, 0);
43 static INT_PTR CALLBACK GfxErrProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
49 SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(
Application.GetInstance(),MAKEINTRESOURCE(
IDI_00_C4X)));
50 SendMessage(hWnd,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(
Application.GetInstance(),MAKEINTRESOURCE(
IDI_00_C4X)));
69 switch(LOWORD(wParam))
78 if(SendMessage(GetDlgItem(hWnd,
IDC_GFXERR_FSCRN),BM_GETCHECK,0,0) == BST_CHECKED)
82 if(resx < 1 || resy < 1)
88 int32_t idx = 0, iXRes, iYRes, iBitDepth;
91 if(iXRes == resx && iYRes == resy)
107 if(resx < 1 || resy < 1)
break;
112 TCHAR selfpath[4096];
113 GetModuleFileName(
nullptr, selfpath, 4096);
114 STARTUPINFOW siStartupInfo;
115 PROCESS_INFORMATION piProcessInfo;
116 memset(&siStartupInfo, 0,
sizeof(siStartupInfo));
117 memset(&piProcessInfo, 0,
sizeof(piProcessInfo));
118 siStartupInfo.cb =
sizeof(siStartupInfo);
119 if (CreateProcessW(selfpath,
nullptr,
120 nullptr,
nullptr, FALSE, 0,
nullptr,
Config.
General.
ExePath.GetWideChar(), &siStartupInfo, &piProcessInfo))
122 CloseHandle(piProcessInfo.hProcess);
123 CloseHandle(piProcessInfo.hThread);
139 while (PeekMessage(&msg,
nullptr, 0, 0, PM_REMOVE) != 0)
141 if (msg.message == WM_QUIT)
break;
142 TranslateMessage(&msg);
143 DispatchMessage(&msg);
147 if (ret == 0 || ret == -1)
150 DWORD err = GetLastError();
152 FORMAT_MESSAGE_ALLOCATE_BUFFER |
153 FORMAT_MESSAGE_FROM_SYSTEM |
154 FORMAT_MESSAGE_IGNORE_INSERTS,
157 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
160 LogF(
"Error in GfxErrorDlg: %d - %s", err,
StdStrBuf((
wchar_t*)lpMsgBuf).getData());
165 if (msg.message == WM_QUIT)
166 PostQuitMessage(msg.wParam);
void ShowGfxErrorDialog()
C4Application Application
const char * LoadResStr(const char *id)
bool LogF(const char *strMessage,...)
StdStrBuf::wchar_t_holder GetWideChar(const char *utf8, bool double_null_terminate=false)
StdStrBuf FormatString(const char *szFmt,...)
bool GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, int32_t *piRefreshRate, uint32_t iMonitor)
C4ConfigGraphics Graphics
static constexpr int COLOR_DEPTH