Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HWND of Webbrowser control

Status
Not open for further replies.

JackTheC

Programmer
Feb 25, 2002
325
NL
Hi,

VFP 9SP2 or VFP 6SP5:

I have a form with an activeX ole control inserted: microsoft webbrowser.
In the properties windows of OleControl1 it shows that there is an HWND property. It says "Write-only" but it also states: Returns the HWND of the current IE window. Strangly enough it only can be seen in the All-tab, not in the Other-tab of the properties window.
I need this HWND property for complicated things i want to do. But it errors to 0x80004005.
How to retrieve the HWND of the webbrowser control. if even possible...


 
I can reproduce, so far so unhelpful.

Googling "Returns the HWND of the current IE window" I find this in whioch shows this is part of the IWebBrowserApp interface.
The VFP Object Browser also shows this in the Microsoft Web Browser control.

I tried to look into several interfaces llike IWebBrowser, IWebBrowser2 and IWebBrowserApp, and they offer
Code:
	PROCEDURE IWebBrowserApp_get_HWND() AS Number;
 				HELPSTRING "Returns the HWND of the current IE window."
	* add user code here
	ENDPROC

But since that also doesn't give you access to private properties of the ole object, this also doesn't help.

I'm out of ideas.

Bye, Olaf.
 
Jack,

I also reproduced your error. I also tried this:

? thisform.MyOleControl.object.hWnd

but that didn't solve it either.

If you don't find a solution, perhaps you could tell us what your overall goal is (the "complicated things" you want to do). Maybe we can suggest some alternative way of doing them.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Yes, as you have the thisform.olecontrol1 reference (or whatever you named your webbrowser control) you already have things under your control. You can even bind to events by defining a class implementing an interface the Webbrowser Control also implements. The Webbrowser control also exposes many of the events without such advanced programming, eg you have the DocumentComplete event (which is not shown as an event in the vfp properties window, but indeed is occurring when the browser has navigated to a url and all dom nodes are created, text is rendered, onload javascript has run etc.)

Bye, Olaf.
 
Thanks guys,

I want to work with the API GetWindowDC. I am converting a program with an external IE via automation into a program with an inserted IE control.
The program uses GetWindowDC and needs a Hwnd of IE. I just found out that I can do the same with the Hwnd of the form and even with the hwnd of FoxPro itself. It seems I don't need the Hwnd of IE anymore.

Thanks for your time and effort.


 
That depends on what you need the DC (device context) for. If you want to send keys you could even use 0, as long as the foxpro app has focus. But you can automate the webbrowser without knowing the DC, you have an object reference, you can get a DOM reference to the document displayed inside the webbrowser control and so on, without knowing the DC.

Bye, Olaf.
 
Believe me, I need a Hwnd. I am changing a program in such a way that IE shows always exactly the same no matter what OS or version of IE. And when I say exactly I mean exactly. pixelprecise. It seems I can do that now with a VFP-form with no titlebar and no borders and a webbrowser control. Just tested on 2x XP, 1x Vista and 3x Win7 (IE 7,8 and 9) and the results are exactly the same. Later this day I will test on Win8.
 
OK, I believe you. All I can add is that the Webbrowser control is always using the render engine of the installed IE version. You can easily tesst with features only the installed IE version supports.

But that may be what you override with a general identical render engine.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top