Quote Originally Posted by VictorN View Post
Please, describe what problem do you have and what exactly you were "not getting".
Thanks sir
we have two project here one is MYDll and next is Test Dll. In MyDll i have created a modal dialog
derived with CDialog and take a method DoModal here like this

//in Header of MyClass.h
public:
__declspec(dllexport) CString SayHello (CString strName);
__declspec(dllexport) CMyClass();
__declspec(dllexport) virtual ~CMyClass();
void DoModal();



// this is in MyClass.cpp
void CMyClass :oModal()
{
CAnand a;
a.DoModal ();

}


Now i want to call this dialog through Dll in My TestDll

In TestDll i have added ExtDllState.h
#ifndef __EXTDLLSTATE_H__
#define __EXTDLLSTATE_H__

class CEXTDLLState
{
public:
CEXTDLLState();
~CEXTDLLState();

protected:
HINSTANCE m_hInstOld;
};

#endif

and ExtDllState.cpp class

static AFX_EXTENSION_MODULE MyDll = { NULL, NULL };

CEXTDLLState::CEXTDLLState()
{
m_hInstOld = AfxGetResourceHandle();
//AfxSetResourceHandle(extensionDLL.hModule);
HINSTANCE hRes=NULL;
hRes=::LoadLibrary ("MyDll.dll");
if(hRes )
AfxSetResourceHandle (hRes );

}

CEXTDLLState::~CEXTDLLState()
{
AfxSetResourceHandle(m_hInstOld);
}

now i am adding TestDllDlg class exact these function

void CTestDLLDlg::OnOK()
{
UpdateData(true);
CString strResult = objMyClass.SayHello(m_edit);
AfxMessageBox (strResult);

//CDialog::OnOK();
}

and

int CTestDLLDlg :oModal()
{

CEXTDLLState State;

return CDialog:oModal();

}

everything is fine but when i debug this i found m_pMainWnd
and debug point reach Winmain.cpp
in thse lines
// Perform specific initializations
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}

So. How i can call this dialog in my second project with Dlls
thanks a lot