In an Extension DLL, you have to make sure that you provide the mechanism
Extension DLL. I have CDynLinkLibrary to do this, which is to build a
resource chain that is searched by your module when it needs the resources.
Others have used AfxSetResourceHandle successfully. That will be something
to look into.
I am trying to convert our DLLs from Regular to Extension, and I ran
into a problem where Create() is now failing for one of my dialogs.
I've narrowed it down to the fact that this dialog has a custom
control. The custom control class is imported from a DLL. Here is
the scenario in more detail:
In DLL1, I have the dialog and code that tries to create it...
class Dialog
{
CustomControl customControl;
};
void onSomeMessage()
{
Dialog.Create(IDD_OF_A_DIALOG_RESOURCE_DEFINED_IN_DLL1);
}
In DLL2, I have an exported custom control that looks like this...
class DLL2_API CustomControl
{
CustomControl()
{
WNDCLASS wndClass;
HINSTANCE hInst = AfxGetInstanceHandle();
if (!::GetClassInfo(hInst, CLASSNAME, &wndClass))
{
wndClass.lpfnWndProc = ::DefWindowProc;
wndClass.cbClsExtra = wndClass.cbWndExtra = 0;
wndClass.hInstance = hInst;
wndClass.hIcon = NULL;
wndClass.hCursor = AfxGetApp()-
LoadStandardCursor(IDC_ARROW);
wndClass.hbrBackground = NULL;
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = CLASSNAME;
if (!AfxRegisterClass(&wndClass))
AfxThrowResourceException();
}
}
};
So far, my focus has been on the call to AfxGetInstanceHandle().
After a bit of research, I saw a post about AfxGetResourceHandle(). I
tried this call instead, but the return value is no different. In
both calls, the return value was the hInstance of the exe. The last
thing I've tried, which seems to have worked, was to use DLL1's
hInstance. The problem is that I hardcoded the value. I'm looking
for the proper solution, not a hack.
Has anyone experienced this sort of problem?
Thanks,
KD