gpt4 book ai didi

c++ - 如何更改左上角 : taskbar, 的图标,按下 Alt-Tab 时的图标,我的 .exe

转载 作者:太空宇宙 更新时间:2023-11-04 13:39:02 27 4
gpt4 key购买 nike

平台:Windows 7

开发环境:VS2013

语言:C++

Windows 类:WinAPI

我有一个自定义图像:Icon.png。

我还有一个来自 msdn 示例代码的 Windows 类,用于创建基本的 Win32 窗口。它有我的 Windows 类结构中的两个东西 hIcon 和 hIconSm,我不确定它们对应的是什么,但它们可能都与图标有关。

我需要:将任务栏的图标更改为 Icon.png,对 exe 左上角的图标执行相同的操作,并更改按下 alt+tab 时显示的图标。

所以这意味着我需要知道我更改了哪些变量、要使用哪些函数以及它的参数代表什么。此外,如果需要在 VS 中单击或创建其他文件,我还需要有关如何执行此操作的说明。

非常感谢任何帮助。

PS 我尝试了其他人在这里发布的内容,但它要么不起作用,要么说明不清楚,因此我询问具体情况。

最佳答案

所以,我找到了自己的答案。

A) 我可以干预资源加载(我这样做了,结果很沮丧,未能成功将其链接到 LoadIcon 函数。

B) 第二种方式:使用 LoadImage 并将返回值强制转换为 HICON(显然是 hacky,但它适用于我试图更改的所有图标!!!!!!所以,问题解决了哈。下面是我在我的项目中使用的伪代码。

   windowclass.hIcon = (HICON) LoadImage( // returns a HANDLE so we have to cast to HICON
NULL, // hInstance must be NULL when loading from a file
"iconfile.ico", // the icon file name
IMAGE_ICON, // specifies that the file is an icon
0, // width of the image (we'll specify default later on)
0, // height of the image
LR_LOADFROMFILE| // we want to load a file (as opposed to a resource)
LR_DEFAULTSIZE| // default metrics based on the type (IMAGE_ICON, 32x32)
LR_SHARED // let the system release the handle when it's no longer used
);

因此,如果您想要对上述内容进行一些其他自定义,我建议您转到 LoadImage 的 MSDN 定义并根据它自定义您的参数。

关于c++ - 如何更改左上角 : taskbar, 的图标,按下 Alt-Tab 时的图标,我的 .exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28480107/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com