Call MFC regular dll from other app
-
Hi, I am trying to call a MFC dialog based regular dll from other application. The dll function "BOOL CApplicationApp::InitInstance()" does not call to any dialog. I want to trigger UI on the click on button so i created a exported function which call first dilaog of application. But when I create a object of class it does load resource I think so crashed. Suggest me how to do?
-
Hi, I am trying to call a MFC dialog based regular dll from other application. The dll function "BOOL CApplicationApp::InitInstance()" does not call to any dialog. I want to trigger UI on the click on button so i created a exported function which call first dilaog of application. But when I create a object of class it does load resource I think so crashed. Suggest me how to do?
You could step into the exported function using a debugger to find what is going on. MFC DLLs require the first line of a function to be -
AFX_MANAGE_STATE(AfxGetStaticModuleState());
If you haven't done that, you could try by putting that as the first line of the exported function.«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)
-
Hi, I am trying to call a MFC dialog based regular dll from other application. The dll function "BOOL CApplicationApp::InitInstance()" does not call to any dialog. I want to trigger UI on the click on button so i created a exported function which call first dilaog of application. But when I create a object of class it does load resource I think so crashed. Suggest me how to do?
The short answer is between very difficult and you can't do this because not all of MFC is thread safe. There are specific parts of MFC designed for threading general background http://msdn.microsoft.com/en-us/library/975t8ks0%28v=vs.90%29.aspx[^] The tips page will give you the specific problem http://msdn.microsoft.com/en-us/library/h14y172e%28v=vs.90%29.aspx#_core_accessing_mfc_objects_from_non_2d_mfc_threads[^] QUOTE:
If you have a multithreaded application that creates a thread in a way other than using a CWinThread object, you cannot access other MFC objects from that thread. In other words, if you want to access any MFC object from a secondary thread, you must create that thread with one of the methods described in Multithreading: Creating User-Interface Threads or Multithreading: Creating Worker Threads. These methods are the only ones that allow the class library to initialize the internal variables necessary to handle multithreaded applications.
In vino veritas