Loading bitmap resource?

Quote
petrijr@sik (Petri Riipinen) wrote:
>Hi there.

>I put a bitmap into my programs RES as I want it to be
>included in the EXE and not as external file. I have to
>load the bitmap runtime. I don't want to use the TImage-
>component in compile time as I have to print this bitmap
>"randomly" in runtime.

>So, I gues the WinApi function LoadBitmap is the way to go?

That's right!

Quote
>What is the application instance? Is it Application.Handle?

Use hInstance if the Bitmap RES file is bound into your EXE

Quote
>But how do I use the handle which LoadBitmap returns?

Create an instance of TBitmap and then call

MyBitmap.Handle := LoadBitmap(hInstance, 'MYBITMAP');

Quote
>I want
>to draw the bitmap on a TPaintBox at runtime. How do I do it?

Use the Draw method of the Paintbox during its OnPaint event handler.

Quote
>Canvas.Draw seems to be fine, but how do I tell it to use
>the loaded bitmap resource?

Draw takes the bitmap as the third parameter, I believe.

--
*LT Nick Hodges, USN                     Naval Postgraduate School      *
*jnhod...@nps.navy.mil                Information Technology Management *
*CIS: 71563,2250 AOL: NHodges                   Monterey, CA            *
*The opinions expressed above are entirely my own and not the Navy's.   *