SFML community forums
Help => Graphics => Topic started by: drpitch on July 08, 2009, 03:23:40 pm
-
Hi all,
I'd like to set an image icon for my application. I'm using C++ on Visual Studio 2008.
I've seen that there's a SetIcon method that receive a pointer to the buffer of the image, but I really don't know how to use it since I've got a HICON:
sf::RenderWindow m_window;
HICON hIcon = (HICON) LoadImage(instance, MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
m_window.SetIcon(32, 32, ???);
Does anyone know how this can be done?
Thanks!
-
It's easier with sf::Image ( and cross-platform :wink: ) .
sf::Image icon;
icon.LoadFrom*(...); // File/Image/Pixel
my_window.SetIcon(icon.GetWidth(), icon.GetHeight(), icon.GetPixelsPtr());
simple, isn't it ?
-
It's easier with sf::Image
I think he wants to load the icon from the executable ;)
There are more cross-platform techniques to achieve that, like converting your icon file to a C++ header, and then using LoadFromMemory functions family in SFML.
If you want to stick with Win32, I think you'll have to lock the resource, obtain a direct pointer on the pixels (maybe after a few conversions to HBITMAP or whatever) and release the resource. MSDN is your best friend.
-
Well, I'd prefer to load the icon from the executable, but loading it from a file it's not a bad solution ;)
I've finally done what Hiura says, after converting the icon to a png file ;)
Thanks!
-
you're welcome :wink:
-
but then the executable icon is a crappy looking window, isnt it?
-
but then the executable icon is a crappy looking window, isnt it?
That's an issue for your compiler.
-
but then the executable icon is a crappy looking window, isnt it?
That's an issue for your compiler.
Belive me or not, you solved my problem :D
Thanks!
BTW, SFML is amazing