VOGONS


First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

I'm trying to modify a Windows-only project based on DOSBox, and the code that I started with uses SDL_NOFRAME (in the SDL_SetVideoMode statement) so that it didn't create a titlebar, border, or icon at the upper-left corner.

I put back the titlebar and border by removing SDL_NOFRAME, but the window now displays a blank icon, despite the fact that I've got a known-good dosbox_log.h in the gui directory and this code near the top of sdlmain.cpp:

static unsigned char logo[32*32*4]= {
#include "dosbox_logo.h"
};
static void GFX_SetIcon() {
#if WORDS_BIGENDIAN
SDL_Surface* logos= SDL_CreateRGBSurfaceFrom((void*)logo,32,32,32,128,0xff000000,0x00ff0000,0x0000ff00,0);
#else
SDL_Surface* logos= SDL_CreateRGBSurfaceFrom((void*)logo,32,32,32,128,0x000000ff,0x0000ff00,0x00ff0000,0);
#endif
SDL_WM_SetIcon(logos,NULL);
}

What am I doing wrong that prevents the icon from appearing in the title bar?

The icon referenced in winres.rc correctly appears as the application icon in Explorer and the taskbar. I'd be happy if I could get it into the titlebar too.

Thanks for any help with this.

EDIT: In the source code of winres.rc I've tried both "#include windows.h" and "#include afxres.h" with no effect on the titlebar icon. I'm using Visual C++ 2010 Professional.

Reply 1 of 1, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

I solved the problem by moving the code into the right place in the file, as in the DOSBox source.

I still can't figure out how to load a BMP file for SDL_SM_SetIcon instead of using dosbox_logo.h, although I've tried to follow the syntax online. But at least I have an icon in the title bar, and that's good enough.

Apologies for wasting bandwidth on a problem I should have solved by myself. Admins, please feel free to delete this whole thread.