如何在taskmanager中更改应用程序图标 [英] How to change app icon in taskmanager

查看:170
本文介绍了如何在taskmanager中更改应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些Windows应用程序可以改变他的图标,使用win api函数

  SendMessage(hwnd,WM_SETICON,ICON_BIG, icon_handle); 
SendMessage(hwnd,WM_SETICON,ICON_SMALL,icon_handle);

Shell_NotifyIcon(...)

它会更改任务栏和托盘(任务栏通知区域)中的图标,但 taskmanager 未更改
如何更改taskmanager中的图标?是否可以?

解决方案

这个答案


重要的是更改所有图标,包括小和大的应用程序:




  //将两个图标更改为同一个图标手柄。 
SendMessage(hwnd,WM_SETICON,ICON_SMALL,hIcon);
SendMessage(hwnd,WM_SETICON,ICON_BIG,hIcon);

//这将确保应用程序图标也被更改。
SendMessage(GetWindow(hwnd,GW_OWNER),WM_SETICON,ICON_SMALL,hIcon);
SendMessage(GetWindow(hwnd,GW_OWNER),WM_SETICON,ICON_BIG,hIcon);






EDIT / p>

根据此SO回答,图标需要由图标编辑器创建的.ICO文件; 此SO文章还提到您需要将消息发送到最顶层的窗口



我可以在任务栏,alt-tab和任务管理器中切换图标

a)创建一个图标使用Visual Studio资源编辑器

b)使用 HICON hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1));

c)发送 WM_SETICON,ICON_SMALL 到最上面的窗口 - 我使用的是MFC SDI应用程序,所以我将消息发送到主框架窗口c $ c> AfxGetApp() - > m_pMainWnd



注意: WM_SETICON的MSDN文档提及


系统不会复制图标。在销毁窗口之前不要销毁图标



I have some windows application that can change his icon, using win api functions

SendMessage(hwnd, WM_SETICON, ICON_BIG, icon_handle);
SendMessage(hwnd, WM_SETICON, ICON_SMALL, icon_handle);

Shell_NotifyIcon(...);

It changes icon in taskbar and tray (taskbar notification area), but icon in taskmanager still not changed. How can I change icon in taskmanager? Is it possible?

解决方案

From this SO answer

It's important to change all icons, including the application, both small and big:

//Change both icons to the same icon handle.
SendMessage(hwnd, WM_SETICON, ICON_SMALL, hIcon);
SendMessage(hwnd, WM_SETICON, ICON_BIG, hIcon);

//This will ensure that the application icon gets changed too.
SendMessage(GetWindow(hwnd, GW_OWNER), WM_SETICON, ICON_SMALL, hIcon);
SendMessage(GetWindow(hwnd, GW_OWNER), WM_SETICON, ICON_BIG, hIcon);


EDIT:

According to the this SO answer, the icon needs to be a .ICO file created by an icon editor; this SO article also mentions that you need to send the message to the top-most window of the application.

I could switch the icon in the task bar, alt-tab and in the task manager by
a) creating an icon using the Visual Studio Resource Editor
b) loading the icon with code like HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
c) sending WM_SETICON, ICON_SMALL to the topmost window -- I was using a MFC SDI application, so I sent the message to the main frame window (AfxGetApp()->m_pMainWnd)

NOTE: a comment in the MSDN Docs for WM_SETICON mentions

The system does not make a copy of the icon. Do not destroy the icon before destroying the window

这篇关于如何在taskmanager中更改应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆