|
From: <ve...@wp...> - 2005-01-28 08:19:12
|
> Now I got a resource editor (ResEd) and it works great !!!
> I can now include all resources to the exe file.
> But how do I load, for example, a bitmap from the recource ???
> resource file:
> picture BITMAP DISCARDABLE "Small.bmp"
> main file:
> int main(int argc, char **argv) {
> HBITMAP hBM;
> // how to load the resource "picture" into this handle ????
>
> }
--begin--
hBM=(HBITMAP)LoadImage(hInst, //application instance
MAKEINTRESOURCE(picture), //id of bitmap
IMAGE_BITMAP, //constant specifying image type
0, //image width, when 0 use resource width
0, //image height, when 0 use resource height
LR_CREATEDIBSECTION|LR_LOADTRANSPARENT); //how to load image
//test to ensure bitmap handle is actually pointing to something useful
if (hBmp)
{
//now get some information about the loaded bitmap, specifically its height and width
BITMAP bm;
GetObject(hBmp,sizeof(bm),&bm);
//we get:
//bm.bmHeight
//bm.bmWidth
}
--end--
taken from http://www.foosyerdoos.fsnet.co.uk/ which i recommend as a
good source of basic info about some win classes and so on.
if ur working on console app (Main, not WinMain and therefore no
hInstance) then make first parameter of LoadImage NULL (u'll use
desktop as the context).
That's it.
Velkyn
|