如何在运行时设置Windows任务栏图标? [英] How to set the Windows taskbar icon during runtime?
问题描述
通常,属于应用程序任务栏按钮的图标与EXE中包含并为程序显示的图标相同。现在,在我的应用程序中,我想动态更改此图标,这意味着在指定(PNG)图像的情况下读取配置。现在,应用程序将加载此图像,并将其设置为新的任务栏图标。
normally the icon that belongs to a application's taskbar-button is the same icon that is contained in the EXE and shown for the program. Now within my application I want to change this icon dynamically, means a configuration is read where a (PNG) image is specified. Now the application loads this image and has to set it as new taskbar icon.
但是:如何完成最后一步?如何在运行时在任务栏中设置图标(不在托盘中!)?
But: how can this last step be done? How do I set the icon in taskbar (not in tray!) during runtime?
谢谢!
推荐答案
发送 WM_SETICON 消息发送到您的窗口,并在其中传递大小( ICON_BIG
或 ICON_SMALL
) wParam
和 lParam
中新图标的句柄。
Send a WM_SETICON message to your window, passing the size (either ICON_BIG
or ICON_SMALL
) in the wParam
and the handle to the new icon in the lParam
.
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
这篇关于如何在运行时设置Windows任务栏图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!