changeset 2016:f696215e6d4e

Win: First attempt at implmenting dw_html_javascript_run() for embedded IE.... Doesn't seem to work but it compiles.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 07 Nov 2019 11:18:46 +0000
parents c30f4354966e
children 686b2d049056
files win/browser.c
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/win/browser.c	Thu Nov 07 10:12:25 2019 +0000
+++ b/win/browser.c	Thu Nov 07 11:18:46 2019 +0000
@@ -1433,6 +1433,29 @@
 
 int _dw_html_javascript_run(HWND hwnd, LPCWSTR script, void *scriptdata)
 {
+	IHTMLWindow2	*htmlWindow2;
+	IOleObject		*browserObject;
+	VARIANT			retVal;
+
+	// Retrieve the browser object's pointer we stored in our window's GWL_USERDATA when
+	// we initially attached the browser object to this window.
+	browserObject = *((IOleObject **)dw_window_get_data(hwnd, "_dw_html"));
+
+	// We want to get the base address (ie, a pointer) to the IWebBrowser2 object embedded within the browser
+	// object, so we can call some of the functions in the former's table.
+	if (!browserObject->lpVtbl->QueryInterface(browserObject, &IID_IHTMLWindow2, (void**)&htmlWindow2))
+	{
+		BSTR myscript = SysAllocString(script);
+		if (myscript)
+		{
+			htmlWindow2->lpVtbl->execScript(htmlWindow2, myscript, NULL, &retVal);
+			SysFreeString(myscript);
+		}
+		// We no longer need the IWebBrowser2 object (ie, we don't plan to call any more functions in it,
+		// so we can release our hold on it). Note that we'll still maintain our hold on the browser
+		// object.
+		htmlWindow2->lpVtbl->Release(htmlWindow2);
+	}
 	return DW_ERROR_UNKNOWN;
 }