my mfc app calls a dll (open source) that sends strings to standard out (cout). How to redirect that to my mfc app during runtime?.
There more than one option to do this. 1. They should provide an option of sending the output to some other window apart from console. 2. You should edit the necessary function to have the same functionality as its open source. 3. You write your own dll to to send the output to your program.
it is a c++ dll (must keep it c++ dll). Not windows dll. its has a class member, int m_counter; Code: void CUpCalss::Func() { for (,,) m_counter++; i like this m_counter get updated in edit control of my mfc gui. } I am not sure how to implement this.
There are lots of ways you can do this. 1. You write the class with _declspec(dllexport) option and you can directly import the class from where the GUI is located. 2. Pass the handler to the edit box where the DLL class can display the output.
i don't get it. if i am calling Func(), then how my mfc app can access m_counter while Func() is running?.
Check out [thread=907]Creating a simple DLL[/thread] article. That will help you to get things moving.
Code: #include "dll.h" void CDll::ATestMethod() { m_c = 0; for (int i = 0; i<1000; i++) m_c++; } can you make the exe app or any other app to show the m_c increment?. i'll keep trying. Specailly in an mfc application.
Pass the handle to the window to the method ATestMethod() where you want to display the data and set the data from method using the handle
Download the code from the above article and add a new function to the DLL Code: void CDll::ATestMethod(HWND hwnd) { CWnd *editbox = CWnd::FromHandle(hwnd); editbox->SetWindowText("Shabbir"); } Now call this method from a dailog based MFC app using the following Code: CDll dll; dll.ATestMethod(m_edt.GetSafeHwnd()); Assuming m_edt is the DDX_Control of the edit box. If you dont get it let me know your email and I will mail the code to you.