From eaab4e3cf5f5e1c2c4c4e41b91082ea76052122c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 4 Apr 2022 21:37:01 +0200 Subject: Size first list view column according to contents. --- c/main.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'c') diff --git a/c/main.c b/c/main.c index cf9818a..2c69d70 100644 --- a/c/main.c +++ b/c/main.c @@ -302,31 +302,35 @@ SetupFonts() void UpdateLayout() { - HWND hElv, hDlv; int cxColumn, cyDlv; RECT rc; + extern HWND HDlv, HElv; static int cxVScroll = 0; GetClientRect(HWnd, &rc); if (!cxVScroll) cxVScroll = GetSystemMetrics(SM_CXVSCROLL); - /* Resize data list view. */ - - hDlv = GetDlgItem(HWnd, IDC_DATALISTVIEW); - cyDlv = rc.bottom - LvHeight(hDlv, 0); - MoveWindow(hDlv, 0, cyDlv, rc.right, rc.bottom, TRUE); +#define SETCOLW(lv) \ + ListView_SetColumnWidth(lv, 0, LVSCW_AUTOSIZE); \ + cxColumn = ListView_GetColumnWidth(lv, 0)+4; \ + ListView_SetColumnWidth(lv, 0, cxColumn); \ + ListView_SetColumnWidth(lv, 1, rc.right-cxColumn-cxVScroll-4); - cxColumn = ListView_GetColumnWidth(hDlv, 0); - ListView_SetColumnWidth(hDlv, 1, rc.right-cxColumn-cxVScroll-4); + /* Resize data list view. */ + SendMessage(HDlv, WM_SETREDRAW, FALSE, 0); + cyDlv = rc.bottom - LvHeight(HDlv, 0); + MoveWindow(HDlv, 0, cyDlv, rc.right, rc.bottom, TRUE); + SETCOLW(HDlv); + SendMessage(HDlv, WM_SETREDRAW, TRUE, 0); /* Resize episode list view. */ + SendMessage(HElv, WM_SETREDRAW, FALSE, 0); + MoveWindow(HElv, 0, 0, rc.right, cyDlv+1, TRUE); + SETCOLW(HElv); + SendMessage(HElv, WM_SETREDRAW, TRUE, 0); - hElv = GetDlgItem(HWnd, IDC_EPISODELISTVIEW); - MoveWindow(hElv, 0, 0, rc.right, cyDlv+1, TRUE); - - cxColumn = ListView_GetColumnWidth(hElv, 0); - ListView_SetColumnWidth(hElv, 1, rc.right-cxColumn-cxVScroll-4); +#undef SETCOLW } /* Try to style application according to current Windows theme. */ -- cgit v1.2.3