Skip to content

Commit

Permalink
Update to PhImageList support
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Jun 4, 2021
1 parent 7876cd8 commit fbf7c5b
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 82 deletions.
10 changes: 5 additions & 5 deletions ProcessHacker/chproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static VOID PhpRefreshProcessList(

ExtendedListView_SetRedraw(Context->ListViewHandle, FALSE);
ListView_DeleteAllItems(Context->ListViewHandle);
ImageList_RemoveAll(Context->ImageList);
PhImageListRemoveAll(Context->ImageList);

process = PH_FIRST_PROCESS(processes);

Expand Down Expand Up @@ -153,14 +153,14 @@ static VOID PhpRefreshProcessList(

if (icon)
{
imageIndex = ImageList_AddIcon(Context->ImageList, icon);
imageIndex = PhImageListAddIcon(Context->ImageList, icon);
PhSetListViewItemImageIndex(Context->ListViewHandle, lvItemIndex, imageIndex);
DestroyIcon(icon);
}
else
{
PhGetStockApplicationIcon(NULL, &icon);
imageIndex = ImageList_AddIcon(Context->ImageList, icon);
imageIndex = PhImageListAddIcon(Context->ImageList, icon);
PhSetListViewItemImageIndex(Context->ListViewHandle, lvItemIndex, imageIndex);
}

Expand Down Expand Up @@ -235,7 +235,7 @@ INT_PTR CALLBACK PhpChooseProcessDlgProc(
MapDialogRect(hwndDlg, &context->MinimumSize);

context->ListViewHandle = lvHandle = GetDlgItem(hwndDlg, IDC_LIST);
context->ImageList = ImageList_Create(PhSmallIconSize.X, PhSmallIconSize.Y, ILC_COLOR32 | ILC_MASK, 0, 40);
context->ImageList = PhImageListCreate(PhSmallIconSize.X, PhSmallIconSize.Y, ILC_COLOR32 | ILC_MASK, 0, 40);

PhSetListViewStyle(lvHandle, FALSE, TRUE);
PhSetControlTheme(lvHandle, L"explorer");
Expand All @@ -253,7 +253,7 @@ INT_PTR CALLBACK PhpChooseProcessDlgProc(
break;
case WM_DESTROY:
{
ImageList_Destroy(context->ImageList);
PhImageListDestroy(context->ImageList);
PhDeleteLayoutManager(&context->LayoutManager);
}
break;
Expand Down
9 changes: 5 additions & 4 deletions ProcessHacker/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ INT_PTR CALLBACK PhOptionsDialogProc(
{
case WM_INITDIALOG:
{
OptionsTreeImageList = ImageList_Create(2, PH_SCALE_DPI(22), ILC_MASK | ILC_COLOR, 1, 1);
OptionsTreeImageList = PhImageListCreate(2, PH_SCALE_DPI(22), ILC_MASK | ILC_COLOR, 1, 1);
OptionsTreeControl = GetDlgItem(hwndDlg, IDC_SECTIONTREE);
ContainerControl = GetDlgItem(hwndDlg, IDD_CONTAINER);

Expand Down Expand Up @@ -350,7 +350,8 @@ INT_PTR CALLBACK PhOptionsDialogProc(
PhDereferenceObject(SectionList);
SectionList = NULL;

if (OptionsTreeImageList) ImageList_Destroy(OptionsTreeImageList);
if (OptionsTreeImageList)
PhImageListDestroy(OptionsTreeImageList);

PhUnregisterWindowCallback(hwndDlg);

Expand Down Expand Up @@ -1495,7 +1496,7 @@ INT_PTR CALLBACK PhpOptionsGeneralDlgProc(

comboBoxHandle = GetDlgItem(hwndDlg, IDC_MAXSIZEUNIT);
listviewHandle = GetDlgItem(hwndDlg, IDC_SETTINGS);
GeneralListviewImageList = ImageList_Create(1, PH_SCALE_DPI(22), ILC_MASK | ILC_COLOR, 1, 1);
GeneralListviewImageList = PhImageListCreate(1, PH_SCALE_DPI(22), ILC_MASK | ILC_COLOR, 1, 1);

PhInitializeLayoutManager(&LayoutManager, hwndDlg);
PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_SEARCHENGINE), NULL, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT);
Expand Down Expand Up @@ -1558,7 +1559,7 @@ INT_PTR CALLBACK PhpOptionsGeneralDlgProc(
DeleteFont(CurrentFontInstance);

if (GeneralListviewImageList)
ImageList_Destroy(GeneralListviewImageList);
PhImageListDestroy(GeneralListviewImageList);

PhClearReference(&NewFontSelection);
PhClearReference(&OldTaskMgrDebugger);
Expand Down
48 changes: 32 additions & 16 deletions ProcessHacker/procprv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3086,21 +3086,19 @@ VOID PhProcessImageListInitialization(

PhImageListItemType = PhCreateObjectType(L"ImageListItem", 0, PhpImageListItemDeleteProcedure);

PhProcessLargeImageList = ImageList_Create(PhLargeIconSize.X, PhLargeIconSize.Y, ILC_MASK | ILC_COLOR32, 100, 100);
PhProcessSmallImageList = ImageList_Create(PhSmallIconSize.X, PhSmallIconSize.Y, ILC_MASK | ILC_COLOR32, 100, 100);
ImageList_SetBkColor(PhProcessLargeImageList, CLR_NONE);
ImageList_SetBkColor(PhProcessSmallImageList, CLR_NONE);
PhProcessLargeImageList = PhImageListCreate(PhLargeIconSize.X, PhLargeIconSize.Y, ILC_MASK | ILC_COLOR32, 100, 100);
PhProcessSmallImageList = PhImageListCreate(PhSmallIconSize.X, PhSmallIconSize.Y, ILC_MASK | ILC_COLOR32, 100, 100);
PhImageListSetBkColor(PhProcessLargeImageList, CLR_NONE);
PhImageListSetBkColor(PhProcessSmallImageList, CLR_NONE);

PhGetStockApplicationIcon(&iconSmall, &iconLarge);
ImageList_AddIcon(PhProcessLargeImageList, iconLarge);
ImageList_AddIcon(PhProcessSmallImageList, iconSmall);
DestroyIcon(iconLarge);
DestroyIcon(iconSmall);
PhImageListAddIcon(PhProcessLargeImageList, iconLarge);
PhImageListAddIcon(PhProcessSmallImageList, iconSmall);

iconLarge = PhLoadIcon(PhInstanceHandle, MAKEINTRESOURCE(IDI_COG), PH_LOAD_ICON_SIZE_LARGE, 0, 0);
iconSmall = PhLoadIcon(PhInstanceHandle, MAKEINTRESOURCE(IDI_COG), PH_LOAD_ICON_SIZE_SMALL, 0, 0);
ImageList_AddIcon(PhProcessLargeImageList, iconLarge);
ImageList_AddIcon(PhProcessSmallImageList, iconSmall);
PhImageListAddIcon(PhProcessLargeImageList, iconLarge);
PhImageListAddIcon(PhProcessSmallImageList, iconSmall);
DestroyIcon(iconLarge);
DestroyIcon(iconSmall);
}
Expand Down Expand Up @@ -3185,8 +3183,8 @@ PPH_IMAGELIST_ITEM PhImageListExtractIcon(

if (largeIcon && smallIcon)
{
newentry->LargeIconIndex = ImageList_AddIcon(PhProcessLargeImageList, largeIcon);
newentry->SmallIconIndex = ImageList_AddIcon(PhProcessSmallImageList, smallIcon);
newentry->LargeIconIndex = PhImageListAddIcon(PhProcessLargeImageList, largeIcon);
newentry->SmallIconIndex = PhImageListAddIcon(PhProcessSmallImageList, smallIcon);
DestroyIcon(smallIcon);
DestroyIcon(largeIcon);
}
Expand Down Expand Up @@ -3246,7 +3244,7 @@ VOID PhDrawProcessIcon(
{
if (PhProcessLargeImageList)
{
ImageList_Draw(
PhImageListDrawIcon(
PhProcessLargeImageList,
Index,
hdc,
Expand All @@ -3260,7 +3258,7 @@ VOID PhDrawProcessIcon(
{
if (PhProcessSmallImageList)
{
ImageList_Draw(
PhImageListDrawIcon(
PhProcessSmallImageList,
Index,
hdc,
Expand All @@ -3279,10 +3277,28 @@ HICON PhGetImageListIcon(
{
if (Large)
{
return ImageList_GetIcon(PhProcessLargeImageList, (ULONG)Index, ILD_NORMAL | ILD_TRANSPARENT);
if (PhProcessLargeImageList)
{
return PhImageListGetIcon(
PhProcessLargeImageList,
(ULONG)Index,
ILD_NORMAL | ILD_TRANSPARENT
);
}
}
else
{
if (PhProcessSmallImageList)
{
return PhImageListGetIcon(
PhProcessSmallImageList,
(ULONG)Index,
ILD_NORMAL | ILD_TRANSPARENT
);
}
}

return ImageList_GetIcon(PhProcessSmallImageList, (ULONG)Index, ILD_NORMAL | ILD_TRANSPARENT);
return NULL;
}

HIMAGELIST PhGetProcessSmallImageList(
Expand Down
6 changes: 3 additions & 3 deletions ProcessHacker/runas.c
Original file line number Diff line number Diff line change
Expand Up @@ -2710,15 +2710,15 @@ INT_PTR CALLBACK PhpRunFileWndProc(
PhSmallIconSize.Y
))
{
context->ImageListHandle = ImageList_Create(
context->ImageListHandle = PhImageListCreate(
PhSmallIconSize.X,
PhSmallIconSize.Y,
ILC_MASK | ILC_COLOR32,
1,
1
);

ImageList_AddIcon(context->ImageListHandle, shieldIcon);
PhImageListAddIcon(context->ImageListHandle, shieldIcon);
DestroyIcon(shieldIcon);
}
}
Expand All @@ -2729,7 +2729,7 @@ INT_PTR CALLBACK PhpRunFileWndProc(
PhSetIntegerSetting(L"RunFileDlgState", Button_GetCheck(context->RunAsCheckboxHandle) == BST_CHECKED);

if (context->ImageListHandle)
ImageList_Destroy(context->ImageListHandle);
PhImageListDestroy(context->ImageListHandle);

PhFree(context);
}
Expand Down
14 changes: 7 additions & 7 deletions ProcessHacker/searchbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ VOID PhpSearchInitializeImages(

Context->ImageWidth = PhSmallIconSize.X + 4; //GetSystemMetrics(SM_CXSMICON) + 4;
Context->ImageHeight = PhSmallIconSize.Y + 4; //GetSystemMetrics(SM_CYSMICON) + 4;
Context->ImageListHandle = ImageList_Create(
Context->ImageListHandle = PhImageListCreate(
Context->ImageWidth,
Context->ImageHeight,
ILC_MASK | ILC_COLOR32,
2,
0
);
ImageList_SetImageCount(Context->ImageListHandle, 2);
PhImageListSetImageCount(Context->ImageListHandle, 2);

if (bitmap = PhLoadPngImageFromResource(PhInstanceHandle, Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE), TRUE))
{
ImageList_Replace(Context->ImageListHandle, 0, bitmap, NULL);
PhImageListReplace(Context->ImageListHandle, 0, bitmap, NULL);
DeleteBitmap(bitmap);
}
else
Expand All @@ -143,7 +143,7 @@ VOID PhpSearchInitializeImages(

if (bitmap = PhLoadPngImageFromResource(PhInstanceHandle, Context->ImageWidth, Context->ImageHeight, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE), TRUE))
{
ImageList_Replace(Context->ImageListHandle, 1, bitmap, NULL);
PhImageListReplace(Context->ImageListHandle, 1, bitmap, NULL);
DeleteBitmap(bitmap);
}
else
Expand Down Expand Up @@ -260,7 +260,7 @@ VOID PhpSearchDrawButton(

if (Edit_GetTextLength(Context->WindowHandle) > 0)
{
ImageList_Draw(
PhImageListDrawIcon(
Context->ImageListHandle,
0,
bufferDc,
Expand All @@ -271,7 +271,7 @@ VOID PhpSearchDrawButton(
}
else
{
ImageList_Draw(
PhImageListDrawIcon(
Context->ImageListHandle,
1,
bufferDc,
Expand Down Expand Up @@ -390,7 +390,7 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(

if (context->ImageListHandle)
{
ImageList_Destroy(context->ImageListHandle);
PhImageListDestroy(context->ImageListHandle);
context->ImageListHandle = NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions ProcessHacker/tokprp.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
HANDLE tokenHandle;

tokenPageContext->ListViewHandle = GetDlgItem(hwndDlg, IDC_GROUPS);
tokenPageContext->ListViewImageList = ImageList_Create(2, 20, ILC_MASK | ILC_COLOR, 1, 1);
tokenPageContext->ListViewImageList = PhImageListCreate(2, 20, ILC_MASK | ILC_COLOR, 1, 1);

PhSetListViewStyle(tokenPageContext->ListViewHandle, TRUE, TRUE);
PhSetControlTheme(tokenPageContext->ListViewHandle, L"explorer");
Expand Down Expand Up @@ -972,7 +972,7 @@ INT_PTR CALLBACK PhpTokenPageProc(
PhSaveListViewColumnsToSetting(L"TokenGroupsListViewColumns", tokenPageContext->ListViewHandle);

if (tokenPageContext->ListViewImageList)
ImageList_Destroy(tokenPageContext->ListViewImageList);
PhImageListDestroy(tokenPageContext->ListViewImageList);

PhpTokenPageFreeListViewEntries(tokenPageContext);

Expand Down
2 changes: 1 addition & 1 deletion phlib/theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ LRESULT CALLBACK PhThemeWindowDrawToolbar(
{
DrawInfo->nmcd.rc.left += 5;

ImageList_Draw(
PhImageListDrawIcon(
toolbarImageList,
buttonInfo.iImage,
DrawInfo->nmcd.hdc,
Expand Down
2 changes: 1 addition & 1 deletion phlib/treenew.c
Original file line number Diff line number Diff line change
Expand Up @@ -5606,7 +5606,7 @@ VOID PhTnpDrawCell(

if (Context->ImageListSupport)
{
ImageList_DrawEx(
PhImageListDrawEx(
Context->ImageListHandle,
(ULONG)(ULONG_PTR)Node->Icon, // HACK (dmex)
hdc,
Expand Down
2 changes: 1 addition & 1 deletion plugins/ExtendedTools/fwtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ BOOLEAN NTAPI FwTreeNewCallback(
break;
}

ImageList_Draw(
PhImageListDrawIcon(
PhGetProcessSmallImageList(),
(ULONG)(ULONG_PTR)node->ProcessIconIndex, // HACK (dmex)
hdc,
Expand Down
5 changes: 3 additions & 2 deletions plugins/HardwareDevices/diskoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,15 +648,15 @@ VOID LoadDiskDriveImages(

if (PhExtractIconEx(deviceIconPath, FALSE, (INT)index, &smallIcon, NULL))
{
Context->ImageList = ImageList_Create(
Context->ImageList = PhImageListCreate(
24, // GetSystemMetrics(SM_CXSMICON)
24, // GetSystemMetrics(SM_CYSMICON)
ILC_MASK | ILC_COLOR32,
1,
1
);

ImageList_AddIcon(Context->ImageList, smallIcon);
PhImageListAddIcon(Context->ImageList, smallIcon);
DestroyIcon(smallIcon);

ListView_SetImageList(Context->ListViewHandle, Context->ImageList, LVSIL_SMALL);
Expand Down Expand Up @@ -721,6 +721,7 @@ INT_PTR CALLBACK DiskDriveOptionsDlgProc(
DiskDrivesSaveList();

FreeListViewDiskDriveEntries(context);
if (context->ImageList) PhImageListDestroy(context->ImageList);

PhRemoveWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
PhFree(context);
Expand Down
5 changes: 3 additions & 2 deletions plugins/HardwareDevices/netoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,15 +734,15 @@ VOID LoadNetworkAdapterImages(
{
if (PhExtractIconEx(dllIconPath, FALSE, (INT)index, &smallIcon, NULL))
{
Context->ImageList = ImageList_Create(
Context->ImageList = PhImageListCreate(
24, // GetSystemMetrics(SM_CXSMICON)
24, // GetSystemMetrics(SM_CYSMICON)
ILC_MASK | ILC_COLOR32,
1,
1
);

ImageList_AddIcon(Context->ImageList, smallIcon);
PhImageListAddIcon(Context->ImageList, smallIcon);
ListView_SetImageList(Context->ListViewHandle, Context->ImageList, LVSIL_SMALL);
DestroyIcon(smallIcon);
}
Expand Down Expand Up @@ -812,6 +812,7 @@ INT_PTR CALLBACK NetworkAdapterOptionsDlgProc(
NetAdaptersSaveList();

FreeListViewAdapterEntries(context);
if (context->ImageList) PhImageListDestroy(context->ImageList);

PhRemoveWindowContext(hwndDlg, PH_WINDOW_CONTEXT_DEFAULT);
PhFree(context);
Expand Down
Loading

0 comments on commit fbf7c5b

Please sign in to comment.