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;
}
|
Go4Expert Founder
|
![]() |
| 3Dec2007,09:26 | #2 |
|
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.
|
|
Newbie Member
|
|
| 3Dec2007,16:46 | #3 |
|
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);
}
Last edited by shabbir; 3Dec2007 at 17:39.. Reason: Code block |
|
Go4Expert Founder
|
![]() |
| 3Dec2007,17:46 | #4 |
|
Try running in the debug mode and see where the program is crashing or giving any ASSERT.
|

