|
Executable icons and window icons |
Aksel Huff
Member #16,201
February 2016
|
Did some searching, all I could really find on this was: https://www.allegro.cc/forums/thread/607514 So I already know I can set the icon of the window with al_set_display_icon(), but I never knew how to set the icon for the executable, and the one that shows up on the taskbar. Well I just figured it out, and now I'm trying to get it to work with Allegro. I like that I can pack the .ico into the executable so I don't need to include a separate png file with executable. If I create a simple C++ app with an icon resource, the executable, the taskbar, and the window all have the icon, but if I'm using Allegro, the window and the taskbar no longer have an icon. Is there anyway for Allegro to let Windows take care of the icon? Thanks
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
I don't think Allegro is self aware enough to detect an embedded icon resource. There are ways to embed the resource in the file as a C array, and then you can use al_load_bitmap_f to load it. Allegro probably changes the icon when it creates the window, and since its not aware of the icon you embedded, it can't use it. Try embedding the icon as a resource file, and using al_set_display_icon at the same time. It's not a fix, but it should work. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
torhu
Member #2,727
September 2002
|
This is the code I use to load the icon resource, the same one that's displayed as the executable's icon. This is always the first icon resource defined. It's called "IDI_ICON1" here, but the name doesn't matter. HWND winhandle; HICON icon; /* Create the display here, before setting the icon. */ icon = LoadIcon(GetModuleHandle(NULL), "IDI_ICON1"); if (icon) { winhandle = al_get_win_window_handle(display); SetClassLongPtr(winhandle, GCLP_HICON, (LONG_PTR)icon); SetClassLongPtr(winhandle, GCLP_HICONSM, (LONG_PTR)icon); }
Aksel Huff said: If I create a simple C++ app with an icon resource, the executable, the taskbar, and the window all have the icon, but if I'm using Allegro, the window and the taskbar no longer have an icon. Is there anyway for Allegro to let Windows take care of the icon? What happens is that Explorer loads the first icon resource in the file (first defined in the .rc), and displays that as the program's icon. The window icon and other icons used at runtime are just generic default icons unless you set them to something else. If your C++ program is created in Visual Studio, maybe you were using a template that already had the code for doing that. |
|