Skip to main content
gamedev.net
🔒 Locked

Problems with LoadBitmap in VisualStudio.net

Started by Boltimus Jun 24, 2004 at 5:08 PM 0 replies 350+ views
Original Post
Boltimus
Boltimus
I started using Visual Studio.net and just trying to get a Bitmap loaded from my resources. Anyhow here's the code I used to load the bitmap.... HBITMAP Base_Bitmap_HANDLE; Base_Bitmap_HANDLE = LoadBitmap(Main_Window, TEXT("IDB_BITMAP1")); error = GetLastError(); sprintf(buf, "GetLastError returned %u\n",error); MessageBox(NULL, buf, "Error", MB_OK); The Messagebox says that GetLastError reports an error 1814, "The specified resource name cannot be found in the image file. " I added the bitmap as a resource, I just don't understand why it's not seeing the bitmap resource that I inserted. Any ideas?? Thanks a bunch!!
~Bolt"All men dream: but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity: but the dreamers of the day are dangerous men, for they may act their dreams with open eyes, to make it possible." This I did...
foniks munkee
foniks munkee
I'm just guessing here, because there are a few variables that you have initialised elsewhere that could be causing the problem. But I can see one thing that generally causes this error.

Now, when you imported the bitmap as a resource, it would have been given a default identifier, something like IDB_BITMAP1. Which you have passed to the LoadBitmap function as a text string. It is in fact (unless you have changed the value of the resource ID to a string), a number. i.e. a variable that represents a number. The variable is defined in the resource header file.

Rather than:
TEXT("IDB_BITMAP1")

try:
MAKEINTRESOURCE(IDB_BITMAP1)

And make sure you have your resource header (defaults to resource.h) included in your project.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.