aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp34
1 files changed, 13 insertions, 21 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 219f4b8..3746bb6 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -17,6 +17,7 @@ int g_bThread;
/* Looked-up constants. */
int g_bThemes;
+int g_cxVScroll;
int g_iDPI = 96;
/* Fonts. */
@@ -159,6 +160,8 @@ static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPAR
g_hWnd = (HWND)wParam;
/* Look up constants. */
+ g_cxVScroll = GetSystemMetrics(SM_CXVSCROLL);
+
if (auto opLib = maybe_make<Library>(TEXT("User32.dll")))
if (auto GetDpiForWindow = opLib->GetProcAddress<UINT(HWND)>("GetDpiForWindow"))
g_iDPI = GetDpiForWindow(g_hWnd);
@@ -502,32 +505,21 @@ INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wPa
void UpdateLayout()
{
- int cxColumn, cyDlv, yStatus;
- RECT rc, rcStatus;
- static int cxVScroll = GetSystemMetrics(SM_CXVSCROLL);
+ if (!g_hWndStatus) return;
- GetClientRect(g_hWnd, &rc);
- GetClientRect(g_hWndStatus, &rcStatus);
- yStatus = rcStatus.bottom-rcStatus.top;
+ RECT rc, rrStatus;
+ 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);
- /* Resize data list view. */
- cyDlv = rc.bottom-yStatus-g_pDlv->Height();
- require(MoveWindow(g_pDlv->hWnd, 0, cyDlv, rc.right, rc.bottom-yStatus-cyDlv, TRUE));
- ListView_SetColumnWidth(g_pDlv->hWnd, DLVSIKEY, LVSCW_AUTOSIZE);
- cxColumn = ListView_GetColumnWidth(g_pDlv->hWnd, 0)+4;
- ListView_SetColumnWidth(g_pDlv->hWnd, DLVSIKEY, cxColumn);
- ListView_SetColumnWidth(g_pDlv->hWnd, DLVSIVALUE, rc.right-cxColumn-cxVScroll-4);
-
- /* Resize episode list view. */
- require(MoveWindow(g_pElv->hWnd, 0, 0, rc.right, cyDlv+1, TRUE));
- ListView_SetColumnWidth(g_pElv->hWnd, ELVSIEPISODE, LVSCW_AUTOSIZE);
- cxColumn = ListView_GetColumnWidth(g_pElv->hWnd, ELVSIEPISODE)+4;
- ListView_SetColumnWidth(g_pElv->hWnd, ELVSIEPISODE, cxColumn);
- cxColumn += ListView_GetColumnWidth(g_pElv->hWnd, ELVSIRATING);
- ListView_SetColumnWidth(g_pElv->hWnd, ELVSITITLE, rc.right-cxColumn-cxVScroll-4);
+ const long cyDlv = rrStatus.top-g_pDlv->Height();
+ require(SetWindowRect(g_pDlv->hWnd, 0, cyDlv, rc.right, rrStatus.top));
+ require(SetWindowRect(g_pElv->hWnd, 0, 0, rc.right, cyDlv+IsThemeActive()));
+ g_pDlv->ResizeColumns(rc);
+ g_pElv->ResizeColumns(rc);
SendMessage(g_pElv->hWnd, WM_SETREDRAW, TRUE, 0);
SendMessage(g_pDlv->hWnd, WM_SETREDRAW, TRUE, 0);