Problems with native Win32api RichEdit control and its IRichEditOle interface

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-10T11:52:14Z Indexed on 2010/05/10 11:54 UTC
Read the original article Hit count: 438

Filed under:
|
|
|

Hi All!

As part of writing custom command (dll with class that implements Interwoven command interface) for one of Interwoven Worksite dialog boxes,I need to extract information from RichEdit textbox.

The only connection to the existing dialog box is its HWND handle; Seemingly trivial task , but I got stuck :

Using standard win32 api functions (like GetDlgItemText) returns empty string. After using Spy++ I noticed that the dialog box gets IRichEditOle interface and seems to encapsulate the string into OLE object. Here is what I tried to do:

IRichEditOle richEditOleObj = null;
IntPtr ppv = IntPtr.Zero;
Guid guid = new Guid("00020D00-0000-0000-c000-000000000046");
Marshal.QueryInterface(pRichEdit, ref guid, out ppv);
richEditOleObj = (IRichEditOle)Marshal.GetTypedObjectForIUnknown(ppv,typeof(IRichEditOle));

judging by GetObjectCount() method of the interface there is exactly one object in the textbox - most likely the string I need to extract. I used GetObject() method and got IOleObject interface via QueryInterface :

if (richEditOleObj.GetObject(0, reObject, GetObjectOptions.REO_GETOBJ_ALL_INTERFACES) == 0) //S_OK
{
IntPtr oleObjPpv = IntPtr.Zero;
try {
IOleObject oleObject = null;
Guid objGuid = new Guid("00000112-0000-0000-C000-000000000046");
Marshal.QueryInterface(reObject.poleobj, ref objGuid, out oleObjPpv);
oleObject = (IOleObject)Marshal.GetTypedObjectForIUnknown(oleObjPpv, typeof(IOleObject));

To negate other possibilites I tried to QueryInteface IRichEditOle to ITextDocument but this also returned empty string; tried to send EM_STREAMOUT message and read buffer returned from callback - returned empty buffer.

And on this point I got stuck. Googling didn't help much - couldn't find anything that was relevant to my issue - it seems that vast majority of examples on the net about IRichEditOle and RichEdit revolve around inserting bitmap into RichEdit control...

Now since I know only basic stuff about COM and OLE , I guess I am missing something important here.

I would appreciate any thoughts suggestions or remarks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about com