Trying to use ITextDocument and got this far

  • Thread starter Thread starter SamSpade
  • Start date Start date
S

SamSpade

I'm trying to use ITextDocument and got this far.

I don't know what to do about defining ITextDocument

Library.WinApi.SendMessage(RichTextBox1.Handle,
Library.Rtf.EM_GETOLEINTERFACE, IntPtr.Zero, mIRichEditOleI)

Dim td As ITextDocument = DirectCast(mIRichEditOleI, ITextDocument)



Can any one help?



PS



In my C# library:

[DllImport("user32.dll")]

public static extern IntPtr SendMessage(IntPtr hwnd, int Msg, IntPtr wParam,

[MarshalAs(UnmanagedType.IUnknown)] out object lParam);

const int EM_GETOLEINTERFACE = 0x400 + 60;
 
SamSpade said:
I'm trying to use ITextDocument and got this far.

I don't know what to do about defining ITextDocument

Library.WinApi.SendMessage(RichTextBox1.Handle,
Library.Rtf.EM_GETOLEINTERFACE, IntPtr.Zero, mIRichEditOleI)

Dim td As ITextDocument = DirectCast(mIRichEditOleI, ITextDocument)



Can any one help?

You need an interop assembly to define ITextDocument for your program.
Think about it, how would the compiler know what methods comprise
ITextDocuemnt. If you have a type library for containing ITextDocument (or
a .dll containing a type library), then just set a project reference to the
dll, this will import the types and allow you to use early binding.

David
 
David Browne said:
You need an interop assembly to define

What does "interop assembly " mean. Does assembly just mean ".DLL" and
interop just mean: "not managed"?
ITextDocument for your program.
Think about it, how would the compiler know what methods comprise
ITextDocuemnt.
I understand this.
If you have a type library for containing ITextDocument (or
a .dll containing a type library), then just set a project reference to the
dll, this will import the types and allow you to use early binding.

Doesn't RichEd32.DLL contain a typelib?

If not can I maintain the library within the IDE. I don't see MIDL listed
amoung the tools.
Is there any typelibrary tools in the IDE. Maybe the objectbrowser?

The type library is just needed for development (does not need to be
distrubited), right?

Thanks very much for the help.
 
Does assembly just mean ".DLL"

No, an assembly is certainly more than that (and managed EXEs are also
assemblies).

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconassembliesoverview.asp

and interop just mean: "not managed"?

No, it's still managed. But the only purpose of the assembly is to
describe native COM types so that you can use those from managed code.

Doesn't RichEd32.DLL contain a typelib?

Not my copy of it, but Riched20.dll does.



Mattias
 
Can I extract it so I can have it as a standalone?

You can write your own declarations if you want, using some of the
attributes in the System.Runtime.InteropServices namespace (ComImport,
ComInterfaceType, MarshalAs and so on). This is of course a bit more
time consuming and more error prone than using TlbImp.



Mattias
 
In the list of COM references I found "tom" which I added but IntelliSense
still does not display any of the tom intefaces (ITextDocument for example).

I also ise thbimp to extract a dll from RICHED20.DLL which is named "tom". I
don't know how to use it except maybe to add a reference to it which I
expect is the same as adding one to RICHED20.DLL.

All I want to do is define a variable of type ITextDocument. I'm sure I can
take it from there.

Thanks for helping



P.S. I tried to use the ObjectBrowser on the tom reference and got a err
message to the effect it did not have project info for it.
 
In the list of COM references I found "tom" which I added but IntelliSense
still does not display any of the tom intefaces (ITextDocument for example).

Did you import the "tom" namespace?

I don't know what else could fail, it works alright here.



Mattias
 
I don't think so. What can I check. I see tom in the references but if I
type "dim aa as" and look for ITextDocument I don't see it. Is that a good
test?

I got tom into the references by browsing to RICHED20.DLL in project set
references.

thanks
 
I did a search of all the projects and found 5 Interop.tom.dll files in my
directories.
I deleted them but when I open the VS something put them all back!
Do you know what is going on?
The projects in this solution are converted from VB6.




SamSpade said:
I don't think so. What can I check. I see tom in the references but if I
type "dim aa as" and look for ITextDocument I don't see it. Is that a good
test?

I got tom into the references by browsing to RICHED20.DLL in project set
references.

thanks
 
Back
Top