Jump to content

Recommended Posts

Posted (edited)

Trying to use this API has been wrecking my head for hours.I can successfully use it to load a bmp from folder, but I'm trying to load a bmp from resource.All I get is error ERROR_RESOURCE_NAME_NOT_FOUND (1814)

int _tmain(int argc, _TCHAR* argv[]){
char c = '1';
HBITMAP hbitmap = NULL;
hbitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(1), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
//hbitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), (LPWSTR)L"test.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
if ( !hbitmap ) 
{std::cout << "Fail" << std::endl << GetLastError() << std::endl; // 1814}
else {
std::cout << "Succeed" << std::endl;
}
std::cin >> c;
return 0;
}
Can anyone see what I'm doing wrong here?

EDIT:The resource bmp is in the same executable.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

I just thought the error was not finding the resource in the exe, it was what popped up in a search.

All the casting is just things I have been trying during the course of getting the function to return

what I expect.

I've got bleeding eyes from reading the msdn page for the func, I just cannot get my head around it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

And you didn't learn your lesson which is don't use magic numbers. There's a reason symbolic names are defined for resources.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...