Loading a Dialog Resource from a separate DLL

Posted on 2003-03-04
Medium Priority
Last Modified: 2013-11-20
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?
Question by:terrys398
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

BeyondWu earned 1000 total points
ID: 8068695
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question