I have a situation where I must use Windows API to retrieve text from a Rich Text Box in another program; I am wondering if there is any way to get the ...'rich text' from it, and not just the plain text.
In this example, ptrHandle is the RichText Control Handle.
if (ptrHandle == null)
return null;
if (ptrHandle == IntPtr.Zero)
return null;
IntPtr ptrLength =
SendMessage(ptrHandle, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);
var nLen = ptrLength.ToInt32();
if (nLen <= 0)
return null;
var strBuffer = new System.Text.StringBuilder(nLen + 1);
SendMessage(ptrHandle, WM_GETTEXT, new IntPtr(nLen + 1), strBuffer);
This is all done in C#. It gets the text out just fine, but it's stripped of formatting, and such. I was hoping I could retrieve all of that as well.