I'm with difficulties for insert a text in a textBox or RichtextBox without repeat.
This is code used:
#include "windows.h" #pragma comment(lib, "user32") void actwnd() { wchar_t lastwindow[MAX_PATH]; wchar_t currentwindow[MAX_PATH]; HWND mainwindow; mainwindow = GetForegroundWindow(); GetWindowText(mainwindow,currentwindow,sizeof(currentwindow)); if(lastwindow==currentwindow) { } else if(lastwindow!=currentwindow) { strcpy ((char*)lastwindow,(char*)currentwindow); String^ strNew = gcnew String(currentwindow); // String^ wnd = gcnew String(reinterpret_cast(currentwindow)); textBox1->Text += strNew; } } // Set interval for 1000ms in test private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) { actwnd(); } Any help will appreciated