OWL NExt - Knowledge Base

[ Home | Contents | Search | Next | Previous | Up ]

Loading resources from DLL file

Date: 11/30/99
Time: 1:20:56 AM


Question:


I would like to store my Dialog Resources in a DLL file rather
than the main executable.
I am trying to internationalize existing programs that would
require languages to be able to be switched on the fly (rather
than providing separate executables). I do not want dialog
resources, except for US English, to be kept in the .EXE, just
loaded on-demand DLL's.

Answer:


Here's some code for creating a dialog from a resource inside a
DLL:

TDialog* dlg = new TDialog(this, "DIALOG", Module);
int retVal = dlg->Execute();
delete dlg;

Note the use of the Module parameter which tells the
constructor which EXE/DLL contains the resource.
Module (declared in module.h) always points to the currently
executing module. To get your app to grab a
resource from a DLL you could do something like:

TModule* resDLL = new TModule("res.dll");

Then use the various resource access methods of TModule as
required.

TDialog* dlg = new TDialog(this, "DIALOG1", resDLL);
resDLL->LoadString("IDS_A_STRING"); // etc

Last changed: July 14, 2001