aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-04 21:37:01 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-04 21:37:01 +0200
commiteaab4e3cf5f5e1c2c4c4e41b91082ea76052122c (patch)
tree98e268eeaef4c371eb011cea8c5fe90e813c645a
parent0c996d6836defcc190a4f071437d95cb1f5140cb (diff)
downloadEpisodeBrowser-eaab4e3cf5f5e1c2c4c4e41b91082ea76052122c.tar.gz
Size first list view column according to contents.
-rw-r--r--c/main.c30
1 files changed, 17 insertions, 13 deletions
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. */