如何使用windows api更改任务栏中的图标 [英] How to change the icon in taskbar using windows api

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

问题描述

我在写一个小窗口应用程序。

I am writing a small windows application.

我想使用nsis脚本创建安装程序。

I want to create a installer using nsis script.

我知道如何使用

更改默认应用程序图标,开始菜单图标和桌面快捷方式图标应用程序图标:!define MUI_ICON$ { INSTALL_ICON}

Application icon : !define MUI_ICON "${INSTALL_ICON}"

开始菜单上的快捷方式: CreateShortCut$ SMPROGRAMS \ $ StartMenuFolder\shorcutName.lnk $ INSTDIR\executableName.exe$ INSTDIR\ $ {INSTALL_ICON}0

Shortcut on start menu : CreateShortCut "$SMPROGRAMS\$StartMenuFolder\shorcutName.lnk" "$INSTDIR\executableName.exe" "" "$INSTDIR\${INSTALL_ICON}" 0

桌面快捷键: CreateShortCut$ DESKTOP\shorcutName.lnk$ INSTDIR\executableName.exe$ INSTDIR\ $ {INSTALL_ICON}0

但我还要更改应用程序窗口左上方显示的图标。
任务管理器中显示的图标和任务栏上显示的图标。我想应该使用winapi来完成。

But I want to also change the icon shown on the top left of the application window. And icon shown in task manager and icon shown on task bar. I think should be done using winapi.

任何帮助都会感激。

>

推荐答案

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

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);

这篇关于如何使用windows api更改任务栏中的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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