From c1e2d5279d09bb9dba1040da41bb5487b32be16d Mon Sep 17 00:00:00 2001 From: freedom Date: Thu, 12 Oct 2023 00:50:57 -0600 Subject: [PATCH] idek if this compiled lol image list --- progmgr/group.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/progmgr/group.c b/progmgr/group.c index 5977d8c..6fbc9d7 100644 --- a/progmgr/group.c +++ b/progmgr/group.c @@ -14,6 +14,7 @@ #include "registry.h" // #define WIN32_LEAN_AND_MEAN #include +#include #include #include #include @@ -92,6 +93,7 @@ HWND CreateGroup(_In_ PGROUP pg) HICON hIconSmall = NULL; HICON hIconTemp = NULL; HWND hWndGroup = NULL; + HIMAGELIST hImageList = NULL; HWND hWndListView = NULL; RECT rcGroupWindow = { 0 }; LVCOLUMN lvc = { 0 }; @@ -168,6 +170,10 @@ HWND CreateGroup(_In_ PGROUP pg) // add the explorer style because it looks good SetWindowTheme(hWndListView, TEXT("Explorer"), NULL); + // get this bad boy an image list + hImageList = ImageList_Create(SM_CXICON, SM_CYICON, ILC_COLOR32, 0, 1); + SetWindowLongPtr(hWndListView, GWLP_USERDATA, (LONG_PTR)hImageList); + // TODO: make sure the groups delete their icons upon destruction! return hWndGroup; @@ -186,6 +192,7 @@ BOOL RemoveGroup(_In_ HWND hWndGroup, _In_ BOOL bEliminate) BOOL bReturn = TRUE; // TODO: do i have to delete the titlebar icons? + // TODO: cleanup the image list as well, IMAGELIST_DESTORY if (bEliminate == TRUE) { @@ -256,12 +263,12 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi) pGroup->cItemArray++; // populate the listview with the relevant information - lvi.mask = LVIF_TEXT; // | LVIF_IMAGE; + lvi.mask = LVIF_TEXT | LVIF_IMAGE; lvi.iItem = pGroup->cItemArray; lvi.iSubItem = 0; lvi.pszText = pItem->szName; lvi.cchTextMax = ARRAYSIZE(pItem->szName); - // lvi.iImage = I_IMAGECALLBACK; + lvi.iImage = I_IMAGECALLBACK; lvi.lParam = (LPARAM)pItem; // copy that bad boy into the listview @@ -359,7 +366,7 @@ UINT CalculateGroupMemory(_In_ PGROUP pGroup, _In_ UINT cItems) // calculate the total amount of items wanted, set // to 16 if there's less than 16 items so we always // have some memory ready - cItemBlock = pGroup->cItemArray + cItems; + cItemBlock = pGroup->cItemArray + cItems; // round the amount of items to the nearest but highest 16 cItemBlock = ((cItemBlock + 16) / 16) * 16; @@ -430,6 +437,40 @@ LRESULT CALLBACK GroupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa break; } + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) + { + case LVN_GETDISPINFO: + { + // TODO: error checking, verify stuff exists first + // before removing/adding/touching it + HIMAGELIST hImageList = NULL; + HICON hIcon = NULL; + PITEM pItem = NULL; + NMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam; + + // first get our item's pointer + pItem = plvdi->item.lParam; + + // then get the pointer to the group's image list + hImageList = (PGROUP)GetWindowLongPtr(hWnd, GWLP_USERDATA); + + // extract that icon son!! + hIcon = ExtractIcon(hAppInstance, (LPWSTR)pItem->szIconPath, pItem->iIconIndex); + + // this is the image + ImageList_AddIcon(hImageList, hIcon); + plvdi->item.iImage = 222; + + DestroyIcon(hIcon); + + return TRUE; + } + } + } + + default: return DefMDIChildProc(hWnd, message, wParam, lParam); }