22 IHTMLDocument2 *document = NULL;
26 IDispatch *document_dispatch = get_Document();
28 if (document_dispatch != NULL) {
32 document_dispatch->QueryInterface(IID_IHTMLDocument2,
37 document_dispatch->Release();
52 if (document != NULL) {
56 SAFEARRAY *safe_array = SafeArrayCreateVector(VT_VARIANT,0,1);
60 SafeArrayAccessData(safe_array,(LPVOID *)&variant);
62 variant->vt = VT_BSTR;
63 variant->bstrVal = content.AllocSysString();
65 SafeArrayUnaccessData(safe_array);
69 document->write(safe_array);
76 ::SysFreeString(variant->bstrVal);
77 variant->bstrVal = NULL;
79 SafeArrayDestroy(safe_array);
88 CComPtr<IDispatch> spScript;
89 HRESULT hr =
GetDocument()->get_Script( &spScript );
96 CComBSTR bstrMember( funcName );
98 hr = spScript->GetIDsOfNames( IID_NULL, &bstrMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid );
105 DISPPARAMS dispparams;
106 memset( &dispparams, 0,
sizeof dispparams );
107 dispparams.cArgs = 0;
108 dispparams.cNamedArgs = 0;
111 const int arraySize = (int) paramArray->GetCount();
112 dispparams.cArgs = arraySize;
113 dispparams.rgvarg =
new VARIANT[ dispparams.cArgs ];
114 for (
int i=0; i< arraySize; i++ )
116 CComBSTR bstr = paramArray->GetAt( arraySize - 1 - i );
117 bstr.CopyTo( &dispparams.rgvarg[i].bstrVal );
118 dispparams.rgvarg[i].vt = VT_BSTR;
123 memset( &excepInfo, 0,
sizeof excepInfo );
124 CComVariant vaResult;
125 UINT nArgErr = (UINT)-1;
128 hr = spScript->Invoke( dispid, IID_NULL, 0, DISPATCH_METHOD, &dispparams, &vaResult, &excepInfo, &nArgErr );
129 if ( 0 < dispparams.cArgs )
131 delete [] dispparams.rgvarg;
143 DWORD bufLen = sIn.GetLength()+1;
144 TCHAR * buf =
new TCHAR[bufLen];
145 UrlCanonicalize( sIn, buf, &bufLen, URL_UNESCAPE );
153 DWORD bufLen = sIn.GetLength()+1;
154 TCHAR * buf =
new TCHAR[bufLen];
155 UrlCanonicalize( sIn, buf, &bufLen, 0 );
CComVariant InvokeScript(LPCTSTR funcName, const CStringArray *paramArray=NULL)
static CString URLEncode(CString sIn)
escape any special characters for use in URLs
void WriteContent(CString content)
Dynamically set the HTML content on the control.
IHTMLDocument2 * GetDocument()
Shortcut method for accessing the ITHMLDocument2 instance.
Web Browser ActiveX wrapper, generated by Visual Studio.
static CString URLDecode(CString sIn)
translate escape sequences into their original characters