diff options
author | John Ankarström <john@ankarstrom.se> | 2022-02-25 15:58:00 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-02-25 15:58:00 +0100 |
commit | 196aeb5a981e184c9eb48a8215639252812f2608 (patch) | |
tree | 4e65e640223307b7714fc6355b9dde0252a248a2 /c/main.c | |
parent | 74a6d0f006b9e0ca6167a5a021e0789aa8ac2a07 (diff) | |
download | EpisodeBrowser-196aeb5a981e184c9eb48a8215639252812f2608.tar.gz |
Small improvements.
Diffstat (limited to 'c/main.c')
-rw-r--r-- | c/main.c | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -20,6 +20,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, { char *rgArgs[2]; HWND hWnd; + LPTSTR tszErr; MSG msg; INITCOMMONCONTROLSEX icc; WNDCLASSEX wc; @@ -28,25 +29,25 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, rgArgs[0] = "episode_browser"; rgArgs[1] = NULL; - if (!PL_initialise(1, rgArgs)) - PL_halt(1); - Attach(); + tszErr = TEXT("Could not initialize Prolog."); + if (!PL_initialise(1, rgArgs)) goto f; + tszErr = TEXT("Could not attach databases."); + if (!Attach()) goto f; /* Initialize window. */ icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; - InitCommonControlsEx(&icc); + tszErr = TEXT("Could not initialize common controls."); + if (!InitCommonControlsEx(&icc)) goto f; HPopupMenu = LoadMenu(NULL, MAKEINTRESOURCE(IDR_POPUPMENU)); HPopupMenu = GetSubMenu(HPopupMenu, 0); + memset(&wc, 0, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); - wc.style = 0; wc.lpfnWndProc = WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); @@ -54,7 +55,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); wc.lpszClassName = TEXT("Episode Browser"); wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - RegisterClassEx(&wc); + tszErr = TEXT("Could not register window class."); + if (!RegisterClassEx(&wc)) goto f; hWnd = CreateWindowEx( 0, @@ -64,7 +66,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, CW_USEDEFAULT, CW_USEDEFAULT, 510, 400, NULL, NULL, hInstance, NULL ); - if (!hWnd) return 0; + tszErr = TEXT("Could not create main window."); + if (!hWnd) goto f; SetupFonts(); ShowWindow(hWnd, nCmdShow); @@ -74,7 +77,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, DispatchMessage(&msg); } + PL_halt(0); return 0; +f: MessageBox(NULL, tszErr, TEXT("Error"), MB_ICONERROR); + PL_halt(1); + return 1; } LRESULT CALLBACK @@ -227,7 +234,6 @@ SetupFonts() hModule = LoadLibrary(TEXT("User32.dll")); if (hModule && GetProcAddress(hModule, "SystemParametersInfoW")) { NONCLIENTMETRICS m; - m.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m, 0); @@ -252,10 +258,9 @@ UpdateLayout() RECT rc; static int cxVScroll = 0; - if (cxVScroll == 0) - cxVScroll = GetSystemMetrics(SM_CXVSCROLL); - GetClientRect(HWnd, &rc); + if (!cxVScroll) + cxVScroll = GetSystemMetrics(SM_CXVSCROLL); /* Resize data list view. */ |