# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1573125526 0 # Node ID f696215e6d4ef0addda3ab779301586dcf0503fe # Parent c30f4354966ea1fc1447e4a09ead310ee9509666 Win: First attempt at implmenting dw_html_javascript_run() for embedded IE.... Doesn't seem to work but it compiles. diff -r c30f4354966e -r f696215e6d4e win/browser.c --- 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; }