|
Issuing Commands to the HTML ViewEric Hartwell, September 1998 While it's possible to get the IDispatch pointer of the COM object and control it directly (see Setting HTML View Text Directly From a String), in some cases that may be overkill. This tech note describes a simpler approach. It's fairly straightforward for an application to call a script function within an HTML page (see Q185127). So, to call a method of your COM object, make a script wrapper function and then call the wrapper.
The sample program calls a script function by name and expects to get a string in return. IDispatchPtr spDisp(spDoc->GetScript()); if (spDisp) { USES_CONVERSION; OLECHAR FAR* szMember = T2OLE(pszFunctionName); DISPID dispid; HRESULT hr = spDisp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid); if (SUCCEEDED(hr)) { COleVariant vtResult; static BYTE parms[] = VTS_BSTR; try { COleDispatchDriver dispDriver(spDisp); dispDriver.InvokeHelper(dispid, DISPATCH_METHOD, VT_VARIANT, (void*)&vtResult, parms, pszArguments); _variant_t vResult(vtResult); strResult = (const char *)(_bstr_t)vResult; } catch (...) {} // Put some real code in here } } Resources:MSDN, Microsoft Knowledge Base, Site Builder Workshop, Platform SDK, etc. |
|