Problem showing MFC dialog from extern DLL
-
Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.
-
Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.
-
Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.
If the dialog resource is actually in the DLL, have you included the following in your
ShowDialogFromDll()
function:AFX_MANAGE_STATE(AfxGetStaticModuleState());
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
-
If the dialog resource is actually in the DLL, have you included the following in your
ShowDialogFromDll()
function:AFX_MANAGE_STATE(AfxGetStaticModuleState());
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
But when i put AFX_MANAGE_STATE(AfxGetStaticModuleState()) before my dialog showing code it crashes my program. I get an assetion in WINCORE.CPP line: 884. It crashes because my DLL app does not have a main window. Damn :D
-
Do you have a RichTextCtrl on your Dialog. If so, you must call AfxInitRichEdit() or AfxInitRichEdit2() before calling your function.
I'm not using rich text. It's blank dialog.
-
Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.
call MFC macro AFX_MANAGE_STATE, before calling any of the MFC functions
May all beings be happy and free...
-
Hy there.:) I have problem showing a dialog from dinamicaly loaded .dll. I use MFC both for my application and for it's plug-ins (dll). And when i try to display dialog from my dll using function ShowDialogFromDll i don't get anithing. Pls help. Thanks in advance.
I tried now creating a modeles dialog and it went fine but i need modal dialog :( Darn :) Any ideas now?
-
But when i put AFX_MANAGE_STATE(AfxGetStaticModuleState()) before my dialog showing code it crashes my program. I get an assetion in WINCORE.CPP line: 884. It crashes because my DLL app does not have a main window. Damn :D
Show your
ShowDialogFromDll()
code.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
-
I tried now creating a modeles dialog and it went fine but i need modal dialog :( Darn :) Any ideas now?
Show the code, how you are invoking the dialog?
Prasad Notifier using ATL
-
Show the code, how you are invoking the dialog?
Prasad Notifier using ATL
First i am using function PlugInProc for exporting PlugIn class. In that class i have a function called ImportFile: BOOL CPlugIn::ImportFile(CString sFile) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CImpOpts dlg; dlg.DoModal(); return TRUE; } And when i call this class function from my main application it crashes. And i know why but i don't know how to fix it. Windows figures that CImpOpts is a part of my main application and tries to load dialog resource (IDD_IMPOPTS) from my main app, but resource is found in my dll. Once again, i am exporting whole class from my dll using this function: CMy3dsImpApp theApp; CPlugIn plg; // CPlugIn is of type MPlugIn extern "C" MPlugIn* PASCAL EXPORT PlugInProc() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return &plg; } I can show modeles dialogs, but i need modal dialog (because i need to stop execution of main application code 'till i do specific code in my plugin).
-
First i am using function PlugInProc for exporting PlugIn class. In that class i have a function called ImportFile: BOOL CPlugIn::ImportFile(CString sFile) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CImpOpts dlg; dlg.DoModal(); return TRUE; } And when i call this class function from my main application it crashes. And i know why but i don't know how to fix it. Windows figures that CImpOpts is a part of my main application and tries to load dialog resource (IDD_IMPOPTS) from my main app, but resource is found in my dll. Once again, i am exporting whole class from my dll using this function: CMy3dsImpApp theApp; CPlugIn plg; // CPlugIn is of type MPlugIn extern "C" MPlugIn* PASCAL EXPORT PlugInProc() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return &plg; } I can show modeles dialogs, but i need modal dialog (because i need to stop execution of main application code 'till i do specific code in my plugin).
I'm not sure, but problem may be resource handle. Can you try this, Use this code before invoking
ImportFile
function.HINSTANCE hResInstCurrApp=AfxGetResourceHandle();
HINSTANCE m_hInstResDLL = LoadLibrary("dllHavingDialog.dll"));
if (hInstResDLL )
{
//set resource handle to this dll
AfxSetResourceHandle( hInstResDLL );
//call you function
AfxSetResourceHandle( hResInstCurrApp);//call freelibaray
}
else
{
//failed to load dll.
}Prasad Notifier using ATL
-
I'm not sure, but problem may be resource handle. Can you try this, Use this code before invoking
ImportFile
function.HINSTANCE hResInstCurrApp=AfxGetResourceHandle();
HINSTANCE m_hInstResDLL = LoadLibrary("dllHavingDialog.dll"));
if (hInstResDLL )
{
//set resource handle to this dll
AfxSetResourceHandle( hInstResDLL );
//call you function
AfxSetResourceHandle( hResInstCurrApp);//call freelibaray
}
else
{
//failed to load dll.
}Prasad Notifier using ATL
It doesn't work but thx.