Kirk Evans

I've seen the article entitled "How to get IHTMLDocument2 from a HWND" which is in C++, and doesn't look like it would be a snap to convert.

I'm wondering if maybe there is a more "dot net centric" way of accomplishing the same thing.




Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

OmegaMan

Instead of copying what is going on, maybe there is alternate way to achieve the same effect in .Net. What is your actual goal of getting a web page from a running process





Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

Kirk Evans

An alternate way to achieve the same effect in .Net. is exactly what I am asking for! Smile

I need to be able to copy the selected text from a web page from an outside application. I can get the handle to the window.






Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

OmegaMan

If the open window is IE, you could use method that I detail on my blog, Getting the HTML Document from IE using C#, otherwise you will need to access the win32 code you mentioned which does it....





Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

Kirk Evans

Thank you OmegaMan, that is very interesting.

I am still hoping to find a C# translation of the C++ code mentioned above. I believe it to be "more universal", and also, I am trying to extract the text from a specific window (hWnd). A very brief look at your code leads me to believe that it loops through any and all explorer windows that might be open - so I wouldn't know for sure that the text I am retreiving is from the window I am interested in.

Anyone else know of a translation of that code






Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

OmegaMan

Check out this article, Automating existing Internet Explorer instances in C# where he uses the document you mentioned as a jumping off point to get the document in IE. YOu could use that code to at least get the windows handle and then you only have to get the IDocument from it you want....





Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

Kirk Evans

I will restate my request, because I have a feeling I'm not making myself clear.

I already have the handle to the window.

There is existing C++ code that does exactly what I want to do. ( Refered to in my first post )

I'm wondering if anyone has converted this code to C#.Net

My question is really rather simple. I don't need a strategy on what to do. I'm lazy and I want to avoid converting that code myself.






Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

CalvinR

Unless someone has posted how to do it online, I don't think you are going to any body here willing to do the work for you. Although if you are willing to pay my consulting fee, I may be wililng to work something out for you.




Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

Kirk Evans

Jeepers - I have to admit that this is getting a little frustrating. No one seems to be taking my question at face value.

I'm not asking anyone to "do the work for me". I'm asking if anyone has a link to the converted code. I don't believe that is such a strange request - I see links to existing code on here very often.

But at this point, I give up!

I do appreciate the responses. I will continue my search elsewhere.






Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

OmegaMan

Kirk Evans wrote:

Jeepers - I have to admit that this is getting a little frustrating. No one seems to be taking my question at face value.

I'm not asking anyone to "do the work for me". I'm asking if anyone has a link to the converted code.



Kirk, I did a search and did not find anything; and I believe no one else has...or they/I would have given you the link. If this project means so much to you then figuring out how to PInvoke to win32 functionality is a valid route.





Re: Visual C# General Is there a way to get IHTMLDocument2 from a HWND in C#.Net?

Kirk Evans

Thank you, OmegaMan.

At this point, figuring out how to PInvoke it appears to be my only option.

I do appreciate the time and energy you have put into this.