Hi there,

I'm trying to get the text from two RichEdit controls which are located in external application, but I can't get the the text with GetWindowText. What is my mistake?

Any help would be much appreciated... Thanks in advance.

Here's the code:

#include <iostream>
#include <fstream>
#include <Windows.h>
#include <Winuser.h>

using namespace std;


HWND hwndApp;
HWND hwndRichEditControl1 ;
HWND hwndRichEditControl2;

void GetWindowAndControls(){

// get the handle for the application, works fine
hwndApp= FindWindow(NULL, L"MyExternalApplication");

// get the handles for the two RichEdit controls, works ok (tested with winID).
hwndRichEditControl1 = FindWindowEx(hwndApp, NULL, L"WindowsForms10.RichEdit20W.app.0.33c0d9d", NULL);
hwndRichEditControl2= FindWindowEx(hwndApp, hwndRichEditControl1, L"WindowsForms10.RichEdit20W.app.0.33c0d9d", NULL);

}


void main()
{

// declare the strings
TCHAR txtApp[10], txt1[10], txt2[10];

// get the application handle and the rich edit handles
GetWindowAndControls();

// this works fine, and get the text from main window
::GetWindowText(hwndApp, txtApp, 10);

// this doesn't work - doesn't get text from RichEdit controls inside main window
//Why? How can I make it work?
::GetWindowTextW(hwndRichEditControl1 , txt1, 10);
::GetWindowTextW(hwndRichEditControl2 , txt2, 10);

}