A way is with a Clipboard Listener by testing the focused window from where a text is copied
For example, a test in a C++/Win32 app, hWnd being the main window :
AddClipboardFormatListener(hWnd);
then in the WndProc :
case WM_CLIPBOARDUPDATE:
{
GUITHREADINFO gui;
ZeroMemory(&gui, sizeof(gui));
HWND hWndForeground = GetForegroundWindow();
if (hWndForeground != NULL)
{
gui.cbSize = sizeof(gui);
GetGUIThreadInfo(GetWindowThreadProcessId(hWndForeground, NULL), &gui);
}
HWND hWndFocus = gui.hwndFocus;
// Test here if hWndFocus = your RichEdit window
// For test, checking of the class name
WCHAR wsClass[255];
GetClassName(hWndFocus, wsClass, 255);
}
break;