Re: embedding bitmap by Steve
Steve
Tue Mar 02 16:19:36 CST 2004
So I've got a nice little function that will get ptr to resources, thank you
for your help.
However, this line:
HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE("IDB_Banner"),
RT_BITMAP);
always returns NULL. I have a bitmap that I have imported into the project
and assigned that ID. I have checked teh DLL's size to see that it indeed
is being included.
The error that I get from GetLastError() states that it can't find the
resource. I feel the problem may be in the first parameter of
FindResource(), NULL. I'm not sure what to pass it here, from MSDN it
sounds to me that NULL would cause it to do what I want, but it's not cuttin
it.
Any more tips in this area? How do I get teh HINSTANCE of my DLL so that I
can pass it in there?
Thanks!
Steve
"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:ugCJqaJAEHA.916@tk2msftngp13.phx.gbl...
> "Steve" <steve@nowhere.com> wrote in message
> news:uEvivXIAEHA.2056@TK2MSFTNGP11.phx.gbl...
> > From what I can find on MSDN, LoadBitmap() is a GDI call
>
> Alert the media! :-)
>
> > I don't want to load a bitmap so much as I want to utilize a project
> > resource and somehow write it to a physical file on disk.
> > It may be that I can do that with LoadBitmap() somehow, I just don't see
> it.
>
> Geez, I swear your previous question spoke of bitmaps. :-)
>
> > Here is another example, let's say that you had an avi file that you
> wanted
> > to embed in your DLL, then create the pyhsical file at runtime... is
that
> > possible?
>
> Yes, of course. Still, the answer involves updating the resource script
> either manually or via the IDE to specify the name of the file that
contains
> the data that you want to add to your application.
>
> At runtime you call FindResource(), LoadResource() and LockResource().
> Together, they will yield a pointer to the data and its length. If you
want
> to create a file from that data at runtime, you can use the standard C++
(or
> C) functions or Win32's CreateFile(), WriteFile(), CloseHandle().
>
> > Thanks for the response,
>
> You are welcome.
>
> Regards,
> Will
>
>