如何在SDL2 / C ++ / Visual Studio 2012 express程序中设置窗口标题栏图标和alt-tab图标? [英] How do I set window titlebar icon and alt-tab icon in SDL2 / C++ / Visual Studio 2012 express program?

查看:398
本文介绍了如何在SDL2 / C ++ / Visual Studio 2012 express程序中设置窗口标题栏图标和alt-tab图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经添加了一个.rc文件到我的项目只有以下:

I have added a .rc file to my project with just the following:

IDI_MAIN_ICON          ICON          "..\\..\\icon_artwork\\windows_icons\\project.ico"  

.ico文件包含16x16,32x32,48x48和256x256分辨率的图标。

The .ico file contains icons at 16x16, 32x32, 48x48 and 256x256 resolutions.

我看到任务栏和浏览器中的图标(因此毫无疑问.ico是成功嵌入在.exe中),但是我在应用程序自己的标题栏和alt-tab中看到默认的Windows 7应用程序图标。

I see the icon in the taskbar and explorer (so there is no doubt the .ico is successfully embedded in the .exe), but I see the default Windows 7 application icon in the application's own title bar, and in alt-tab.

有办法在所有情况下,让操作系统看到嵌入式图标本身,或者我需要为此编写一些应用程序代码?我注意到有一个SDL2函数

Is there a way to get the OS to see the embedded icon by itself in all cases, or do I need to write some application code for this? I notice that there is an SDL2 function

void SDL_SetWindowIcon(SDL_Window*  window, SDL_Surface* icon)  

但是它需要一个SDL表面,而不是可执行文件中嵌入的图标资源。

but that takes an SDL surface, not the embedded icon resource from the executable.

任何想法非常感谢,

Tony

Any ideas gratefully received,
Tony

推荐答案

您应该能够获得SDL_Surface .png文件使用

You should be able to get a SDL_Surface from a .png file using

SDL_Surface *IMG_Load(const char *file)

然后将它传递到您的 SDL_SetWindowIcon(SDL_Window *窗口,SDL_Surface *图标)方法。
我不认为 IMG_Load(...)方法,但是一个32x32的.png版本的图标将是一个很好的妥协...
不理想,但最好的解决方法,我可以想到;)

then pass it to your SDL_SetWindowIcon(SDL_Window* window, SDL_Surface* icon) method. I don't think the IMG_Load(...) method takes .ico files though, but a 32x32 .png version of your icon would be a good compromise... Not ideal but the best workaround I can think of ;)

这篇关于如何在SDL2 / C ++ / Visual Studio 2012 express程序中设置窗口标题栏图标和alt-tab图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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