Can anyone help.
How to display a dialog box and handle its message from a dll using MFC.
Thank for your time.
Printable View
Can anyone help.
How to display a dialog box and handle its message from a dll using MFC.
Thank for your time.
I hope that I understood your problem correct.
Once I had the problem that my DialogBox was not shown by using DoModal();
In my case it was a Setting of the project.
=> use Use MFC in a Static Library
instead of Use MFC in a Shared DLL
Actually what I understood from your question is,you are trying to export a dialog box from a extension dll and you want that dialog box to be called from ur application.
If what u meant is the above, then try to export your dialog class using AFX_EXT_CLASS.And create a global function which will return a pointer to a object of that dialog calss.In that function create an object and return the pointer.
Like this..
class AFX_EXT_CLASS a: CDialog
{
//All member functions should be virtual
}
extern "C" __declspec(dllexport) a* CreateObjA(void)
{
return new a();
}
and in the calling app.
define like this
typedef a* (*fnpCreateDlg)(void);
try to load the dll,and get the function address using GetProcAddress of CreateObjA.
fnpCreateDlg fCreateA = (fnpCreateDlg) GetProcAddress(hDllHandle,"CreateObjA");
a *Dlga= (*fCreateA)();
Dlga->DoModal();
try this...It works for me..
PS: Don't forget to use
AfxGetResourceHandle &
AfxSetResourceHandle