App icon sometimes not appearing on window titlebar

I’m just wondering if anyone knows what could cause this. It mostly
seems to happen in Windows, but I’ve occasionally seen it Linux as
well.

I’m referring to the icon which appears in the top left of the window,
which lists operations that can be performed. I assumed this icon was
set with SDL_WM_SetIcon. Strange this is, sometimes the icon doesn’t
appear in the taskbar for the window either, and sometimes it does. I
can’t see a pattern for why it’s happening. Here’s the relevant code,
which loads from an XPM file:

SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(icon, 32, 32, 32,
32 * 4, 0xFF0000, 0x00FF00, 0x0000FF,
0xFF000000);
SDL_WM_SetIcon(surface, (unsigned char *) mask);

Anybody have any advice?

Steve

I ran into something similar. You need to make sure you call
SDL_WM_SetIcon() before you call SDL_SetVideoMode().

Ken Rogoway
Homebrew Software
http://www.homebrewsoftware.com/> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Stephen Anthony
Sent: Sunday, March 30, 2008 9:17 AM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: [SDL] App icon sometimes not appearing on window titlebar

I’m just wondering if anyone knows what could cause this. It mostly seems
to happen in Windows, but I’ve occasionally seen it Linux as well.

I’m referring to the icon which appears in the top left of the window, which
lists operations that can be performed. I assumed this icon was set with
SDL_WM_SetIcon. Strange this is, sometimes the icon doesn’t appear in the
taskbar for the window either, and sometimes it does. I can’t see a pattern
for why it’s happening. Here’s the relevant code, which loads from an XPM
file:

SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(icon, 32, 32, 32,
32 * 4, 0xFF0000, 0x00FF00, 0x0000FF,
0xFF000000);
SDL_WM_SetIcon(surface, (unsigned char *) mask);

Anybody have any advice?

Steve


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

No virus found in this incoming message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.1 - Release Date: 3/26/2008 12:00
AM

No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.22.1 - Release Date: 3/26/2008 12:00
AM

But would that cause it to work sometimes, and not other times? Also,
is there any harm in calling the method more than once per application
invocation (basically, if you destroy and recreate the window, it is OK
to call the function again)?

SteveOn March 30, 2008 3:10:17 pm Ken Rogoway wrote:

I ran into something similar. You need to make sure you call
SDL_WM_SetIcon() before you call SDL_SetVideoMode().

Hi,

Stephen Anthony wrote:> On March 30, 2008 3:10:17 pm Ken Rogoway wrote:

I ran into something similar. You need to make sure you call
SDL_WM_SetIcon() before you call SDL_SetVideoMode().

But would that cause it to work sometimes, and not other times? Also,
is there any harm in calling the method more than once per application
invocation (basically, if you destroy and recreate the window, it is OK
to call the function again)?

I did run into the same problems on the “Enigma” project
(http://www.nongnu.org/enigma). Every OS had need of another SDL
handling and even the different Windows versions did prove to be
incompatible (XP is an exception, 95,98, 2000, Vista are the same)

You will find the handling for Linux, all Windows, Mac OS X in the file:

http://svn.berlios.de/wsvn/enigma-game/trunk/src/video.cc

(Sorry this file would need some cleanup)

The main comment I added last year to the sources:

// Set the caption icon – due to SDL doc it has to be set before first
SDL_SetVideoMode() !!
// In praxis this SetIcon does not work for Linux, nor is it necessary
for OSX.
// Just XP with selected “WindowsXP Design” needs this SetIcon.
// See video::Init() for icon set for Linux and other Windows versions
// Mac icon is set via Makefile

I would really appreciate a simple unified SDL handling of this problem.

Greets,

Ronald

Stephen Anthony wrote:

I ran into something similar. You need to make sure you call
SDL_WM_SetIcon() before you call SDL_SetVideoMode().

But would that cause it to work sometimes, and not other times?
Also, is there any harm in calling the method more than once per
application invocation (basically, if you destroy and recreate the
window, it is OK to call the function again)?

I did run into the same problems on the “Enigma” project
(http://www.nongnu.org/enigma). Every OS had need of another SDL
handling and even the different Windows versions did prove to be
incompatible (XP is an exception, 95,98, 2000, Vista are the same)

OK, thanks for the code. I just looked at it, and it seems the only
difference is that you call SDL_WM_SetIcon() at different times;
sometimes before SDL_SetVideoMode() and sometimes after.

However, I just noticed something else; the way I do it (icon before
video mode) only causes a problem when using the normal XP theme. When
I use the old Win98/2000 theme, the icon works fine!

Does anyone know what could be causing this?
SteveOn March 30, 2008 3:56:06 pm Ronald Lamprecht wrote:

On March 30, 2008 3:10:17 pm Ken Rogoway wrote: