Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   User DLL doesn't work when using CButton (http://www.go4expert.com/forums/user-dll-doesnt-using-cbutton-t7679/)

n559br 3Dec2007 07:38

User DLL doesn't work when using CButton
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
DLLAPI MyClass();
DLLAPI DoModal();

CButton aBtn;

shabbir 3Dec2007 09:26

Re: User DLL doesn't work when using CButton
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.

n559br 3Dec2007 16:46

Re: User DLL doesn't work when using CButton
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.

#define APIDLL _declspec(dllimport)

// aDialog dialog

class CModTest2Dlg: public CDialog

        APIDLL CModTest2Dlg(CWnd* pParent = NULL);  // standard constructor
        APIDLL int DoModal();


int CModTest2Dlg::DoModal()
void CImportClassDlg::OnBnClickedBtnTest()
        CModTest2Dlg aDlg;
        // TODO: Add your control notification handler code here
                HINSTANCE hClientResources = AfxGetResourceHandle();


shabbir 3Dec2007 17:46

Re: User DLL doesn't work when using CButton
Try running in the debug mode and see where the program is crashing or giving any ASSERT.

All times are GMT +5.5. The time now is 15:55.