C# GUI – redirect std::cout from DLL to GUI textbox
I am trying to redirect console output to the textbox. I nearly have it, but I don’t understand why the output from DLL is still printed to console. All the rest calls were printed to the textbox. How it looks now:
Based on that answer I am using StringWriter object. But
private void button2_Click(object sender, EventArgs e) { StringWriter stringw = new StringWriter(); Console.SetOut(stringw); Console.WriteLine("abcd1"); Program.DisplayFloat(7); // <-------- extern dll call Console.WriteLine("abcd2!"); Console.WriteLine("abcd3!"); logBox.AppendText(stringw.ToString()); logBox.AppendText("abcd4"); }
Could you help me? what is the easiest way to redirect output from my C++ dll to textbox?