From ab20d2ec8c3d8d429b60cd06029a24ca26e51806 Mon Sep 17 00:00:00 2001 From: freedom7341 Date: Mon, 2 Oct 2023 16:22:26 -0600 Subject: [PATCH] item dialog icon --- progmgr/dialog.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/progmgr/dialog.c b/progmgr/dialog.c index 3f2d491..6791b97 100644 --- a/progmgr/dialog.c +++ b/progmgr/dialog.c @@ -325,10 +325,14 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l SetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)szNameBuffer); // let's get the icon now - if (ExtractIcon(hAppInstance, &szFileBuffer, -1) != 0) + if (ExtractIcon(hAppInstance, (LPWSTR)szFileBuffer, -1) > 0) { - // file contains at least one icon - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex); + // file contains at least one icon, set the itm struct values + StringCchCopy(itm.szIconPath, ARRAYSIZE(itm.szIconPath), szFileBuffer); + itm.iIconIndex = 1; + + // update icon + hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); } @@ -368,7 +372,7 @@ BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM l if (PickIconDlg(hWndDlg, (LPWSTR)&itm.szIconPath, ARRAYSIZE(itm.szIconPath), &itm.iIconIndex) == TRUE) { // Since we've got the new icon... - hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&itm.szIconPath, itm.iIconIndex); + hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)itm.szIconPath, itm.iIconIndex); SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0); }