• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

Loading a Dialog Resource from a separate DLL

I've browsed through many of the similar questions, and none seem to address this issue, so here it goes...

I'm trying to do the usual Internationalization task of separating the GUI resources from the code.  I've compiled the resources into a separate DLL from the code that runs the GUI.  (Note: I'm using MFC on Windows CE)

Typically, if the resources weren't in a different file, the code would look like this:

MyDialog pDlg;

Since my code for MyDialog is in a different DLL, I've attempted the following, which must be incorrect since it doesn't work:

g_hresource = LoadLibrary (TEXT("resourceDLL.dll"));

HGLOBAL hGlbl = LoadResource(g_hresource,FindResource(g_hresource, (const unsigned short *) IDD_MYDIALOG, RT_DIALOG));


MyDialog pDlg;



Now, any ideas on how to do this correctly?
1 Solution
CDialog::DoModal() always use AfxGetResourceHandle(); to get current resource handle, no matter which dll you has loaded, so you should separate ALL resources into a dll, then in the CWinAPP::InitInstance() or other initialization functions, you need to load your separate resource only dll, then use following code to set the resource handle.
g_hresource = LoadLibrary (TEXT("resourceDLL.dll"));
You needn't change other code at all.
good luck.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now