Re: Showing dialog in DLL
Code:
__declspec(dllexport) void Test();
Instead of exporting a function, export the entire class.
Code:
__declspec(dllexport)class CMyClass
2 Attachment(s)
Re: Showing dialog in DLL
Quote:
I've also tried using macro AFX_MANAGE_STATE, but same error.
Code:
void CMyClass::Test()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
CDialog1 dlg;
dlg.DoModal();
print_last_error();
}
Re: Showing dialog in DLL
Thanks Igor!!
Sorry about that. I was so certain that I already tried that. I must have made a mistake then, since it obviously works :-)
Re: Showing dialog in DLL
Quote:
When method "Test" is called from another MFC application, the dialog is not shown and GetLastError returns error 87 "The parameter is incorrect". I've also tried using macro AFX_MANAGE_STATE, but same error. (Attached zipped project).
Please help. What parameter??
The parameter it was about is dialog resource. As long as you failed to specify proper resource handle, the resource was searched in the .exe module resources (default resources). And obviously the search failed, and provided resource id was reported as invalid parameter.
Funny thing, it might be a situation when the dialog resource with the same resource id could be there. In such case you would have some absolutely different dialog window attached to DLL class. :)