IonicWind Software

IWBasic => General Questions => Topic started by: LarryMc on August 30, 2008, 08:12:13 PM

Title: Bitmaps and resources
Post by: LarryMc on August 30, 2008, 08:12:13 PM
This question is directed to Sapero but anyone can answer.

Sapero,
About 3 years ago, in a ListView program you used the following to load a bitmap, scaling it as it loaded:
hBitmap2 = LoadImageA(0, getstartpath+"images\\b1.bmp", IMAGE_BITMAP, w,h, LR_LOADFROMFILE)
The scaling is an undocumented feature of the LoadImage command (supposedly only works for Icons and Cursers)
The command above works great for me.

However, I want the bitmaps to be in a resource.
I have a bitmap in a resource with an ID of 201.
I want to load it with the scaling just like with the external bitmap.
I tried this without success:
hBitmap2 = LoadImageA(0, "201", IMAGE_BITMAP, w,h, 0)and thishBitmap2 = LoadImageA(0, MAKEINTRESOURCE(201), IMAGE_BITMAP, w,h, 0)
Don't know what else to try.

Larry
Title: Re: Bitmaps and resources
Post by: Ionic Wind Support Team on August 30, 2008, 09:10:15 PM
Larry,

The first parameter has to be the instance handle to the executable or DLL that you are loading the resource from.

hInstance = GetModuleHandle(0)

Returns the instance handle of the running executable. 

A quick look at the sources, or MSDN docs that I gave you a link to, would have given you the answer as well.

Paul.
Title: Re: Bitmaps and resources
Post by: LarryMc on August 30, 2008, 09:14:25 PM
Quote from: Paul Turley on August 30, 2008, 09:10:15 PM
A quick look at the sources, or MSDN docs that I gave you a link to, would have given you the answer as well.

I looked; looked; and looked somemore at all that.
That doesn't mean it registers or means anything to me. ;)

Thanks for taking the time.

Larry
Title: Re: Bitmaps and resources
Post by: LarryMc on August 30, 2008, 09:19:36 PM
Yep,

This did it; scaling and all.
hInstance = _GetModuleHandle(0)
hBitmap2 = LoadImageA(hInstance, "#201", IMAGE_BITMAP, w,h, 0)


Thanks again

Larry