Hi,
I've generated a DLL from a MFC dialog-based project and loaded this DLL onto another MFC dialog-based project.
it can load the dialog from the DLL. But when i need to open a new file from the dialog, the program will just
hang there. I am using a File Dialog and a worker thread to run the function of the open button.
In the button:
this->UpdateData();
RunThread();
this->UpdateData(FALSE);
In the worker thread:
CFileDialog FileDlg(TRUE, ".txt", NULL, OFN_NOCHANGEDIR, strFilter);
if( FileDlg.DoModal() == IDOK )
{
}
HINSTANCE m_hViewDll;
typedef CRuntimeClass * (*GETDLLVIEW)();
AfxEnableControlContainer();
m_hViewDll = AfxLoadLibrary(".\\ProjectA.dll");
if (!m_hViewDll)
{
AfxMessageBox("Error: Cannot find component \"ProjectA.dll\"");
return FALSE;
}
GETDLLVIEW GetView = (GETDLLVIEW) GetProcAddress(m_hViewDll,
"RunMainframe");
ASSERT (GetView != NULL);
if (m_hViewDll)
{
AfxFreeLibrary(m_hViewDll);
m_hViewDll = NULL;
}
class __declspec( dllexport ) CProjectAApp;
extern "C" __declspec( dllexport ) CProjectAApp* RunMainframe();
class __declspec( dllexport ) CProjectADlg;
CProjectAApp* RunMainframe()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()) ;
CProjectAApp* myapp=new CProjectAApp();
myapp->InitInstance();
myapp->Run();
return myapp;
}
How can i solve this problem? and it would be great if someone can explain to me why this happpen so that I can learn from it.
Thank you for helping.