aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 72d405b..746bf7e 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -107,7 +107,7 @@ int WINAPI WinMain(const HINSTANCE hInstance, const HINSTANCE, char* const, cons
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
wc.lpszClassName = TEXT("Episode Browser");
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
@@ -207,7 +207,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
switch (uMsg) {
case WM_CREATE:
UpdateTheme();
- SetWindowPos(hWnd, NULL, -1, -1, Dpi(510), Dpi(400), SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE);
+ SetWindowPos(hWnd, NULL, -1, -1, Dpi(510), Dpi(412), SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE);
SetFocus(g_pElv->hWnd);
/* Set menu item checkmarks according to saved settings. */
@@ -227,7 +227,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
break;
case WM_SIZE:
SendMessage(g_hWndStatus, WM_SIZE, wParam, lParam);
- UpdateLayout();
+ UpdateLayout(LOWORD(lParam), HIWORD(lParam));
break;
case WM_GETMINMAXINFO:
{
@@ -248,7 +248,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
lpr->right-lpr->left,
lpr->bottom-lpr->top,
SWP_NOZORDER|SWP_NOACTIVATE));
- UpdateLayout();
+ UpdateLayout(lpr->right-lpr->left, lpr->bottom-lpr->top);
break;
}
case WM_ACTIVATE:
@@ -506,35 +506,32 @@ INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wPa
return TRUE;
}
-void UpdateLayout()
+void UpdateLayout(int w, int h)
{
if (!g_hWndStatus) return;
RECT rc, rrStatus;
- require(GetClientRect(g_hWnd, &rc));
+ if (w && h) rc = {0, 0, w, h};
+ else require(GetClientRect(g_hWnd, &rc));
require(GetRelativeRect(g_hWndStatus, &rrStatus));
- /* Resize list views. */
- SendMessage(g_pDlv->hWnd, WM_SETREDRAW, FALSE, 0);
- SendMessage(g_pElv->hWnd, WM_SETREDRAW, FALSE, 0);
-
- /* If a modern theme is used, list view borders should be
- * hidden. This variable governs that. (See how it is used in
- * the arguments to SetWindowRect below.) */
- const long x = IsThemeActive();
-
- const long cyDlv = rrStatus.top-g_pDlv->Height();
- require(SetWindowRect(g_pDlv->hWnd, -x, cyDlv, rc.right+x*2, rrStatus.top+x));
- require(SetWindowRect(g_pElv->hWnd, -x, -x*2, rc.right+x*2, cyDlv+x));
- g_pDlv->ResizeColumns();
- g_pElv->ResizeColumns();
+ SendMessage(g_hWnd, WM_SETREDRAW, FALSE, 0);
- SendMessage(g_pElv->hWnd, WM_SETREDRAW, TRUE, 0);
- SendMessage(g_pDlv->hWnd, WM_SETREDRAW, TRUE, 0);
+ /* Resize list views. */
+ const long pad = IsThemeActive()? Dpi(6): 0; /* Add padding in modern themes. */
+ const long cyDlv = rrStatus.top-g_pDlv->Height()-pad;
+ require(SetWindowRect(g_pDlv->hWnd, pad, cyDlv, rc.right-pad, rrStatus.top-pad));
+ require(SetWindowRect(g_pElv->hWnd, pad, pad, rc.right-pad, cyDlv-pad));
+ g_pDlv->ResizeColumns(rc.right-pad-pad);
+ g_pElv->ResizeColumns(rc.right-pad-pad);
/* Resize status bar parts. */
const int aParts[] = {rc.right-Dpi(55), rc.right};
SendMessage(g_hWndStatus, SB_SETPARTS, (WPARAM)sizeof(aParts), (LPARAM)aParts);
+
+ SendMessage(g_hWnd, WM_SETREDRAW, TRUE, 0);
+ RedrawWindow(g_hWnd, NULL, NULL,
+ RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN);
}
/* Try to style application according to current Windows theme. */