0
votes

I have successfully made a resource only DLL, and placed some dialogs, that were in the main exe. So I have Test.exe, and TestENU.dll. It works fine, but I am trying to find a way to only override some dialogs, instead of being required to have all exactly the same dialogs, and instead pull some from the base exe, as my real project has around 40 dialogs, and I only want to have to translate some, slowly over time.

(I used this link to do satellite/resource dll) http://msdn.microsoft.com/en-us/library/8fkteez0(v=vs.90).aspx

2

2 Answers

1
votes

Default resources (including dialogs) are governed by the current setting of the resource handle. You can set the resource handle at any time using AfxSetResourceHandle to point to a resource only dll, or, your executable. You'll need to be prudent in making sure that the handle is pointing to the correct resource location before instantiating a dialog, so, you'll need to save the current handle before changing it to a new resource handle, and, changing it back when you are done.

1
votes

Pass a template ID to the constructor of your dialogs.

Constructor:

CTestDlg::CTestDlg(int Template, CWnd* pParent = NULL) : CDialog(Template)
{   
    ...

Call:

int idd;
if (bTestDialogTranslationExists)
    idd = IDD_TESTDIALOG_FROM_DLL;
else
    idd = IDD_TESTDIALOG;
CTestDialog dlg(idd);
dlg.DoModal();

This code is for demonstration only. You might want to derive a new class from CDialog that handles localized dialog templates automatically, depending on, for example, if the Template exists in a replacement map.

// have this as a global variable or in your CWinApp class
CMap <int, int, int, int> translatedDialogsMap;

// put this maybe in you CWinApp::InitInstance before any dialog could possibly be displayed
translatedDialogsMap[IDD_TESTDIALOG]  = IDD_TESTDIALOG_FROM_DLL;
translatedDialogsMap[IDD_TESTDIALOG2] = IDD_TESTDIALOG2_FROM_DLL;
translatedDialogsMap[IDD_TESTDIALOG3] = IDD_TESTDIALOG3_FROM_DLL;

...

// check in your dialog subclass constructor code, if a mapped dll dialog exists
int idd_replaced;
if (translatedDialogsMap.Lookup(Template, &idd_replaced))
    Template = idd_replaced;