aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/episodelistview.c7
-rw-r--r--c/main.c31
2 files changed, 20 insertions, 18 deletions
diff --git a/c/episodelistview.c b/c/episodelistview.c
index 040383a..c2d937b 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -10,7 +10,6 @@ extern HFONT HfBold;
extern HWND HWnd;
HWND HElv;
LPLVITEM LpLviElvSelection;
-WNDPROC ElvPrevProc;
HWND
ElvCreate()
@@ -63,8 +62,7 @@ ElvHandleNotify(LPARAM lParam)
break;
case CDDS_ITEMPREPAINT:
if (!Watched(lpLvCd->nmcd.lItemlParam)) {
- SelectObject(lpLvCd->nmcd.hdc,
- HfBold);
+ SelectObject(lpLvCd->nmcd.hdc, HfBold);
return CDRF_NEWFONT;
}
break;
@@ -213,10 +211,9 @@ e: Fd(f2);
/* Reset selection and scrolling position. */
ElvSetTop(iTop);
- if (LpLviElvSelection) {
+ if (LpLviElvSelection)
ListView_SetItemState(HElv, LpLviElvSelection->iItem,
LVIS_SELECTED, LVIS_SELECTED);
- }
SendMessage(HElv, WM_SETREDRAW, TRUE, 0);
ElvRedraw();
diff --git a/c/main.c b/c/main.c
index 95026a1..c3e1be1 100644
--- a/c/main.c
+++ b/c/main.c
@@ -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. */