diff options
author | John Ankarström <john@ankarstrom.se> | 2022-02-18 20:25:42 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-02-18 20:25:42 +0100 |
commit | 74a6d0f006b9e0ca6167a5a021e0789aa8ac2a07 (patch) | |
tree | e9210118b3d4ddfafd2965023a90ef9249984a47 /c | |
parent | 6722589a74abb76b8aaff9ba592c5608b024dbde (diff) | |
download | EpisodeBrowser-74a6d0f006b9e0ca6167a5a021e0789aa8ac2a07.tar.gz |
Resize data list view depending on number of items.
Diffstat (limited to 'c')
-rw-r--r-- | c/datalistview.c | 2 | ||||
-rw-r--r-- | c/defs.h | 2 | ||||
-rw-r--r-- | c/listview.c | 9 | ||||
-rw-r--r-- | c/main.c | 16 |
4 files changed, 16 insertions, 13 deletions
diff --git a/c/datalistview.c b/c/datalistview.c index 6749af7..385b384 100644 --- a/c/datalistview.c +++ b/c/datalistview.c @@ -92,5 +92,7 @@ n: free(tszKey); } } + UpdateLayout(); + e: Fd(f); } @@ -8,7 +8,7 @@ TCHAR *TszFromSz(const char *, int); int Watched(int); /* main.c */ -void UpdateLayout(HWND); +void UpdateLayout(); /* listview.c */ HWND LvCreate(HMENU); diff --git a/c/listview.c b/c/listview.c index e37b280..48b61e1 100644 --- a/c/listview.c +++ b/c/listview.c @@ -28,16 +28,15 @@ LvCreate(HMENU hMenu) LvPrevProc = (WNDPROC)SetWindowLongPtr(hLv, GWLP_WNDPROC, (LONG_PTR)LvProc); - ListView_SetExtendedListViewStyleEx(hLv, - LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER); + ListView_SetExtendedListViewStyle(hLv, LVS_EX_FULLROWSELECT); SendMessage(hLv, WM_SETFONT, (WPARAM)HfNormal, MAKELPARAM(FALSE, 0)); hModule = LoadLibrary(TEXT("uxtheme.dll")); if (hModule && GetProcAddress(hModule, "SetWindowTheme")) { - ListView_SetExtendedListViewStyle(hLv, - LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER); + ListView_SetExtendedListViewStyleEx(hLv, + LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER); SendMessage(hLv, WM_CHANGEUISTATE, MAKEWPARAM(UIS_SET, UISF_HIDEFOCUS), 0); SetWindowTheme(hLv, TEXT("Explorer"), NULL); @@ -53,7 +52,7 @@ LvProc(HWND hLv, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case HDN_ENDTRACK: - UpdateLayout(GetParent(hLv)); + UpdateLayout(); return TRUE; } break; @@ -88,7 +88,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PostQuitMessage(0); break; case WM_SIZE: - UpdateLayout(hWnd); + UpdateLayout(); break; case WM_CREATE: HWnd = hWnd; @@ -244,22 +244,24 @@ SetupFonts() /***/ void -UpdateLayout(HWND hWnd) +UpdateLayout() { HWND hElv, hDlv; - int cxColumn, cyDlv; + int cxColumn, cyDlv, iCount; + LOGFONT lf; RECT rc; static int cxVScroll = 0; if (cxVScroll == 0) cxVScroll = GetSystemMetrics(SM_CXVSCROLL); - GetClientRect(hWnd, &rc); + GetClientRect(HWnd, &rc); /* Resize data list view. */ - hDlv = GetDlgItem(hWnd, IDC_DATALISTVIEW); - cyDlv = rc.bottom-100; + hDlv = GetDlgItem(HWnd, IDC_DATALISTVIEW); + iCount = ListView_GetItemCount(hDlv); + cyDlv = rc.bottom - (iCount ? 27+iCount*19 : 0); MoveWindow(hDlv, 0, cyDlv, rc.right, rc.bottom, TRUE); cxColumn = ListView_GetColumnWidth(hDlv, 0); @@ -268,7 +270,7 @@ UpdateLayout(HWND hWnd) /* Resize episode list view. */ - hElv = GetDlgItem(hWnd, IDC_EPISODELISTVIEW); + hElv = GetDlgItem(HWnd, IDC_EPISODELISTVIEW); MoveWindow(hElv, 0, 0, rc.right, cyDlv+1, TRUE); cxColumn = ListView_GetColumnWidth(hElv, 0); |