I am trying to make a user DLL which includes the MFC derived class CButton (or really any MFC class). If I leave the CButton class out the dll runs great. As soon as I include the CButton member the executable causes a trap as soon as DoModal is called. Any ideas? #define DLLAPI _declspec(dllexport) class MyClass : CDialog { DECLARE_DYNAMIC(MyClass) public: DLLAPI MyClass(); DLLAPI DoModal(); CButton aBtn; }
You probably need to see what is there in DoModal() - If you have overridden it or if you have something in the class which you have missed to initialize.
I don't think it's in DoModal. The program will show the dialog, but after returning and making a call to SetResourceHandle I get e run time error that says the stack around aDlg has been corrupted. The calling program and class header are below. Code: #define APIDLL _declspec(dllimport) // aDialog dialog class CModTest2Dlg: public CDialog { public: APIDLL CModTest2Dlg(CWnd* pParent = NULL); // standard constructor APIDLL int DoModal(); }; int CModTest2Dlg::DoModal() { CDialog::DoModal(); return(0); } void CImportClassDlg::OnBnClickedBtnTest() { CModTest2Dlg aDlg; // TODO: Add your control notification handler code here HINSTANCE hClientResources = AfxGetResourceHandle(); AfxSetResourceHandle(::GetModuleHandle("MxModSim.dll")); aDlg.DoModal(); AfxSetResourceHandle(hClientResources); }