|
// Load a resource from a given instance
#pragma once
#ifndef RESOURCE_TO_CSTRING
#define RESOURCE_TO_CSTRING
// Comments Doxygen compatible
/** Load a resource from a given instance
* It seems that if you are in a DLL, the standard MFC checks the instance of the App, then each DLL in the order loaded. This is no good if someone else is using the same ID!
* @param hInst the instance to load from
* @param ids the id to load.
* @ingroup global
*/
inline CString LoadStringFromDLL(HINSTANCE hInst, int ids)
{
// (c) 1998-2000 Golden Crater Software, All rights reserved.
// You may freely use this code
// You may freely redistribute this code, provided this comment block remains intact.
// The body of this function is from the epAssist EAX SDK:
// Use plain English to control your PC over email, AppBar, and soon voice telephone.
// Check out this free SDK that allows you to interface to epAssist.
// Easily add natural language functionality to your application and
// provide your users with access to your program from anywhere they
// can send and receive email (2-way pagers, public terminals and email
// enabled telephones included.) MFC AppWizard and HTML Help, and sample
// source included. http://www.goldencrater.com/software
if (!hInst) {
ASSERT(0);
return "Error loading resource.";
}
CString str;
TCHAR szTemp[256]; // Raise limit of 255 char if needed.
int nLen;
LPCTSTR lpszName = MAKEINTRESOURCE((ids>>4)+1);
if (::FindResource(hInst, lpszName, RT_STRING) != NULL &&
(nLen = ::LoadString(hInst, ids, szTemp, 255) != 0)) {
str = szTemp;
}
return str;
}
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Jim is the President of Golden Crater Corp. (formerly Golden Crater Software) which produces:
Tiny eBook Reader - Read eBooks anywhere, on any web enabled device or phone.
Doberman BMS - Home Automation and Building Management System bridging and enhancing several automation hardware platforms.