Click to See Complete Forum and Search --> : dialogs in dlls?


ericJA
May 1st, 1999, 06:07 PM
I'm creating a dll for a Visual Basic program.
It works fine when I just put a messagebox and run
it because it shows up in the vb program but
when i try to load the dialog I created it doesnt show up
I'm not sure if I'm doing it correctly
( using VC++ 6.0) and created a mfc dll project
that supports both win32 and mfc.
Any ideas?

Here is the code that loads the dialog:

extern "C" int WINAPI dlg();

extern "C" int WINAPI dlg()
{
CTest testDlg;

testDlg.DoModal();
testDlg.ShowWindow( SW_SHOW);
return MessageBox( NULL, "SDFSDF", "SDFDSSD", MB_OK );
}

CTest is a c++ class created using classwizard

BrianOG
May 4th, 1999, 10:04 AM
Unless your dll is an MFC Extention Dll you will need to explicitly set the resource handle so that the MFC will look for the dialog resource in your dll as opposed to the calling application.

Try this:

CTest testDlg;

HINSTANCE hOldRsrcInst = AfxGetResourceHandle();
AfxSetResourceHandle(theApp.m_hInstance);

testDlg.DoModal();

if ( hOldRsrcInst )
AfxSetResourceHandle(hOldRsrcInst);