How to load BMP from .EXE as Windows Resource

I’ve looked at everything in Google and the (outdated) MSDN for an example of loading a BMP from a Windows resource in support of my OpenGL screensaver, but no joy.

I’m getting error code 1814 back from GetLastError() after a CBitmap::LoadBitmap fails which is basically saying: “can’t find yer fargin resource in yer fargin EXE u knob”.

There is no obvious reason why it won’t load; the 256x256 BMP is happily imported in the resource file as IDB_BITMAP1 (ID 110 as it happens) but I’m ready to pull out what little hair I have left.

Does anyone have a cogent source example that works?

Many thanks in advance… Go Raiders!

Nehe at has a tutorial showing how to do this. I think it is tutorial 38.

Good luck,

There’s something wrong with the NeHe tutorial that I have fixed in my own code. They get the actual bits for the bitmap from the bmBits variable in the BITMAP structure they receive from GetObject(). However, the bmBits pointer is always null. You have to use the GetDIBits() function.

[This message has been edited by Tokage (edited 01-26-2003).]


Here’s an example of how to load a Bitmap from resource and display it in a Screensaver: Screensaver Skeleton 3.1

Hope this helps.

  • VC6-OGL


1.0E06 thanks to all for your help… Have a bandit day!

Boo Raiders!