System menu icon?

Hi,

In my SDL game I noticed that when running in windowed mode on Windows,
the system menu icon (the thing in te upper left corner) is a default
icon.

While researching how to set that icon I found out that on Windows you
need to call “RegisterClassEx” instead of “RegisterClass”.

I have written a small patch for SDL-1.2.9 to do that. I hope it can be
included in the next version :slight_smile:

I according to the documentation of RegisterClassEx it is available
since Windows95, and the only change between RegisterClassEx and
RegisterClass are the addition of the two (cbSize and hIconSm) fields in
the struct. So there shouldn’t be any compability problems.

On a related note: I failed compiling a static version of SDL for
windows (it only works when I disable directx), can anyone help me out?

— src/video/wincommon/SDL_sysevents.c.org 2004-02-16 22:09:24.000000000 +0100
+++ src/video/wincommon/SDL_sysevents.c 2005-11-28 00:42:04.000000000 +0100
@@ -579,7 +579,7 @@
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
{
static int initialized = 0;

  • WNDCLASS class;
  • WNDCLASSEX class;
    #ifdef WM_MOUSELEAVE
    HMODULE handle;
    #endif
    @@ -612,6 +612,8 @@
    strcpy(SDL_Appname, name);
    }
    #endif /* _WIN32_WCE */
  • class.cbSize = sizeof(WNDCLASSEX);
  • class.hIconSm = LoadIcon(hInst,SDL_Appname);
    class.hIcon = LoadImage(hInst, SDL_Appname, IMAGE_ICON,
    0, 0, LR_DEFAULTCOLOR);
    class.lpszMenuName = NULL;
    @@ -625,7 +627,7 @@
    class.lpfnWndProc = WinMessage;
    class.cbWndExtra = 0;
    class.cbClsExtra = 0;
  • if ( ! RegisterClass(&class) ) {
  • if ( ! RegisterClassEx(&class) ) {
    SDL_SetError(“Couldn’t register application class”);
    return(-1);
    }

CU,
Sec–
Never test for an error condition you don’t know how to handle.
Steinbach’s Guideline for Systems Programming

Stefan Sec Zehl wrote:

Hi,

In my SDL game I noticed that when running in windowed mode on Windows,
the system menu icon (the thing in te upper left corner) is a default
icon.

While researching how to set that icon I found out that on Windows you
need to call “RegisterClassEx” instead of “RegisterClass”.

What about that function instead :
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fWM_5fSetIcon ?

Well, as far as I understood it, it wouldn’t set the “System Menu” icon
on windows, but I admit that I didn’t test it because I had the icon
already in my resource file, and didn’t want to add it as .bmp again.

Whats worse, I made a mistake while debugging the missing icon (changed
two things at the same time) and wrongly conluded it must’ve been
RegisterClassEx which made the icon appear.

In fact, the only neccessary change is to name the app “SDL_app” in your
windows resource file. Assuming there is an icon of the right size in
your windres file, it works fine with stock SDL-1.2.9.

Sorry for the confusion. %)
SecOn Tue, Nov 29, 2005 at 23:44 +0100, Christophe Cavalaria wrote:

Stefan Sec Zehl wrote:

Hi,

In my SDL game I noticed that when running in windowed mode on Windows,
the system menu icon (the thing in te upper left corner) is a default
icon.

While researching how to set that icon I found out that on Windows you
need to call “RegisterClassEx” instead of “RegisterClass”.

What about that function instead :
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fWM_5fSetIcon ?


I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone.
– Bjarne Stroustrup

Stefan Sec Zehl wrote:

In fact, the only neccessary change is to name the app “SDL_app” in your
windows resource file. Assuming there is an icon of the right size in
your windres file, it works fine with stock SDL-1.2.9.

Any details on how to do that for us non-Windows-programmers? All my
resource file contains is a line “101 ICON pipmak.ico”, I suppose I have
to add some other line that somehow contains “SDL_app”?

(I could probably find that out myself by a bit of googling and
trial-and-error, but as you seem to have solved the problem already,
asking you seems easier :slight_smile: )

-Christian

Any details on how to do that for us non-Windows-programmers? All my resource
file contains is a line “101 ICON pipmak.ico”, I suppose I have to add some
other line that somehow contains “SDL_app”?

I’ve at least used resource files containing “SDL_app ICON file.ico”,
which makes SDL use the icon automatically.

// MartinOn Fri, 2 Dec 2005, Christian Walther wrote:

Martin Storsj? wrote:

Any details on how to do that for us non-Windows-programmers? All my
resource file contains is a line “101 ICON pipmak.ico”, I suppose I
have to add some other line that somehow contains “SDL_app”?

I’ve at least used resource files containing “SDL_app ICON file.ico”,
which makes SDL use the icon automatically.

Right, that works. Thanks!

-Christian

Simply replace the 101 with SDL_app.

You can see my (simple) resource file here, which also contains a
VERSIONINFO block with example values according to the MSDN
documentation.

http://cvs.sourceforge.net/viewcvs.py/brillion/brillion/res.rc?view=markup

Have fun,
SecOn Fri, Dec 02, 2005 at 09:30 +0100, Christian Walther wrote:

Any details on how to do that for us non-Windows-programmers? All my
resource file contains is a line “101 ICON pipmak.ico”, I suppose I have
to add some other line that somehow contains “SDL_app”?


perl -nle ‘print “$_ is divisible by 7” if (unpack(“B*”,reverse pack(“L”,$_))=~
/^0*((1((0(01|1(0010)11)(00|1(0010)10))|1(010(1(10)*11)0)010(1(10)
11)1(10)0)(1(010(1(10)*11)*0)1|0(01|1(0010)*11)1(0010)01))0)+$/x)’