Sign in to follow this  
tlg

[.net] TGA Resources

Recommended Posts

Damn this has bugging me for a few days now - feel like my head is gonna explode! Its Visual Studio .net ... hope that qualifies for this forum. Basically, I want to add 32bit tga files to the projects as resources. So, creating a custom resource type ("TGA") went fine, its just loading the resource that is a pain in the arse. I want to just get a pointer to the data, so I checked out MSDN and followed its instructions - FindResource, LoadResource, LockResource. But it doesn't work - FindResource ALWAYS fails. I've tried FindResourceEx aswell - still fails. And there is one final annoyance. MSDN says NULL is returned on error, for extended information, call GetLastError(). So I put some code after FindResource(Ex) fails to tell me what the problem is. And I get anice messagebox saying "The Operation Completed Successfully"!!!! HRSRC res = FindResource(GetModuleHandle(0), MAKEINTRESOURCE(ID_PARTICLE_IMAGE), "TGA"); if (res == NULL) { FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); MessageBox( NULL, (LPCTSTR)lpMsgBuf, "and Windows says...", MB_OK | MB_ICONINFORMATION ); LocalFree( lpMsgBuf ); } I've tried replacing the first FindResource parameter with NULL, I've tried manually calling LoadLibrary on the exe (which succeeds), and passing the module handle to FindResource but still FindResource fails. I fired up PE Explorer just to make sure that the resource was getting compiled, and it is. Please please help a guy who is completely befounded by a problem that windows claims isn't happening. Regards, Tim [Edited by - tlg on August 18, 2004 7:17:33 AM]

Share this post


Link to post
Share on other sites
It works now. I haven't changed anything, I haven't messed around with the source code, I just went and had some lunch. Came back and hit F5, and the thing worked! weird huh?

Share this post


Link to post
Share on other sites

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

Sign in to follow this