1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

User DLL doesn't work when using CButton

Discussion in 'C' started by n559br, Dec 3, 2007.

  1. n559br

    n559br New Member

    Joined:
    Nov 30, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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;
    }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    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.
     
  3. n559br

    n559br New Member

    Joined:
    Nov 30, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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 a moderator: Dec 3, 2007
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Try running in the debug mode and see where the program is crashing or giving any ASSERT.
     

Share This Page