mfc dll crash
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: mfc dll crash

  1. #1
    Join Date
    Feb 2013
    Posts
    8

    mfc dll crash

    a MFC dll using ActiveX control, consider the case when the content of Start() is uncommented, and within OpenDialog(), AFX_MANAGE_STATE(AfxGetStaticModuleState( )); is commented. In this case the MFC dll crashes when executing the dlg.DoModal();. Otherwise it works ok. not certain why?.Start() is called first.

    Code:
    BOOL CQBDllApp::InitInstance()
    {
    	AfxOleInit();
    	AfxEnableControlContainer();
    	CoInitialize(NULL);
    
    	return CWinApp::InitInstance();
    }
    
    void CQBClass::Start()
    {
    	//AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
    }
    
    void CQBClass::OpenDialog()
    {
    	AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
    	dlg.DoModal();
    }

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: mfc dll crash

    Is it a regular MFC DLL? Then have a look at AfxGetStaticModuleState
    BTW, Why do you use an empty method
    Code:
    void CQBClass::Start()
    {
    	//AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
    }
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: mfc dll crash

    AFX_MANAGE_STATE works in function scope only. This is why calling it in a separate function makes no sense.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center