Главная страница | назад





Article #16449: Dialog resource in a DLL

 Question and Answer Database

FAQ1449C.txt   Dialog resource in a DLL
Category   :OWL
Platform    :All
Product    :BC++  5.x

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

7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99