JohnOne Posted July 23, 2012 Share Posted July 23, 2012 (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 July 24, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted July 23, 2012 Share Posted July 23, 2012 All I get is error ERROR_RESOURCE_NAME_NOT_FOUND (1814)Did you check what that error means? It's not very descriptive, you should try googling.What's with C style casting? JohnOne 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2012 Author Share Posted July 23, 2012 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. Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2012 Author Share Posted July 23, 2012 (edited) Solvedhbitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(101), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);I has no Idea a resource would start at 101.EDIT:tags Edited July 23, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
wraithdu Posted July 23, 2012 Share Posted July 23, 2012 I was just about to ask if you were sure your resource was really where you told the function to look.... Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2012 Author Share Posted July 23, 2012 (edited) I was just about to ask if you were sure your resource was really where you told the function to look....Cheers, I should have posted my woes earlier. Edited July 23, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Valik Posted July 23, 2012 Share Posted July 23, 2012 And you didn't learn your lesson which is don't use magic numbers. There's a reason symbolic names are defined for resources. Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2012 Author Share Posted July 23, 2012 I semi learnt it, I did define int IDB_BITMAP1 = 101; But I'm unsure if it already defined in a header I should have, which I have not. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Valik Posted July 23, 2012 Share Posted July 23, 2012 What IDE are you using? Link to comment Share on other sites More sharing options...
JohnOne Posted July 23, 2012 Author Share Posted July 23, 2012 (edited) Visual Studio 2010. EDIT: Ah, I finally found it. resource1.h Edited July 23, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Valik Posted July 23, 2012 Share Posted July 23, 2012 Not sure why it's resource1.h, it should be resource.h. But yeah, that's the file. Link to comment Share on other sites More sharing options...
JohnOne Posted July 24, 2012 Author Share Posted July 24, 2012 That works too, and makes more sense, I found the #include "resource1.h" in the "project.rc" file. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now