From 36a6d1a8882cc8888fd72538055668cee58f1304 Mon Sep 17 00:00:00 2001 From: freedom7341 Date: Wed, 11 Oct 2023 12:18:18 -0600 Subject: [PATCH] positions correctly on initialization now --- progmgr/group.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/progmgr/group.c b/progmgr/group.c index 823abc6..024334f 100644 --- a/progmgr/group.c +++ b/progmgr/group.c @@ -92,6 +92,7 @@ HWND CreateGroup(_In_ PGROUP pg) HICON hIconTemp = NULL; HWND hWndGroup = NULL; HWND hWndListView = NULL; + RECT rcGroupWindow = { 0 }; LVCOLUMN lvc = { 0 }; if (pg == NULL) @@ -145,6 +146,9 @@ HWND CreateGroup(_In_ PGROUP pg) DestroyIcon(hIconTemp); } + // get the group window rect + GetClientRect(hWndGroup, &rcGroupWindow); + // Create the group window ListView control if ((hWndListView = CreateWindowEx(WS_EX_LEFT, WC_LISTVIEW, TEXT("ListView"), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN @@ -154,6 +158,12 @@ HWND CreateGroup(_In_ PGROUP pg) NULL)) == NULL) return NULL; + // resize it to fit the window + SetWindowPos(hWndListView, NULL, + rcGroupWindow.left, rcGroupWindow.top, + rcGroupWindow.right - rcGroupWindow.left, + rcGroupWindow.bottom - rcGroupWindow.top, SWP_NOZORDER); + // create a ListView name column lvc.mask = LVCF_FMT | LVCF_WIDTH; lvc.fmt = LVCFMT_LEFT; @@ -402,11 +412,10 @@ LRESULT CALLBACK GroupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa break; // resize it to fit the window - if ((rcGroupWindow.left != rcGroupWindow.right) && (rcGroupWindow.top != rcGroupWindow.bottom)) - SetWindowPos(hWndListView, NULL, - rcGroupWindow.left, rcGroupWindow.top, - rcGroupWindow.right - rcGroupWindow.left, - rcGroupWindow.bottom - rcGroupWindow.top, SWP_NOZORDER); + SetWindowPos(hWndListView, NULL, + rcGroupWindow.left, rcGroupWindow.top, + rcGroupWindow.right - rcGroupWindow.left, + rcGroupWindow.bottom - rcGroupWindow.top, SWP_NOZORDER); break; }