// here's a helper function for displaying useful error messages BOOL ProcessHResult(HRESULT hr, IUnknown* p, const IID& iid) { if( hr == S_OK ) return true; // otherwise, throw a _com_issue_errorex and catch it (so we can use it to get // the error description out of it for us. try { _com_issue_errorex(hr, p, iid); } catch(_com_error & er) { if( er.Description().length() > 0) { ::MessageBox(NULL, er.Description(), strCaption, MB_OK); } else { ::MessageBox(NULL, er.ErrorMessage(), strCaption, MB_OK); } } return false; }
inline _variant_t IScriptControl::Run ( _bstr_t ProcedureName, SAFEARRAY * * Parameters ) { VARIANT _result; VariantInit(&_result); HRESULT _hr = raw_Run(ProcedureName, Parameters, &_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _variant_t(_result, false); }
inline _variant_t IScriptModule::Eval ( _bstr_t Expression ) { VARIANT _result; VariantInit(&_result); HRESULT _hr = raw_Eval(Expression, &_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _variant_t(_result, false); }
void CJSOpenView::OnFileWindowOpen() { HRESULT hr; CString str; try { CComQIPtr<IHTMLDocument2> document = GetHtmlDocument(); if (document != NULL) { IHTMLWindow2Ptr window; document->get_parentWindow(&window); if (window != NULL) { CComBSTR url; document->get_URL(&url); CComPtr<IHTMLWindow2> newwin; if (FAILED(hr = window->open(url, CComBSTR(L"_blank"), CComBSTR(), false, &newwin))) { _com_issue_errorex(hr, window, IID_IHTMLWindow2); } printf(""); } } } catch (_com_error err) { AfxMessageBox(CString(err.ErrorMessage()), MB_ICONEXCLAMATION); } }
inline IScriptProcedureCollectionPtr IScriptModule::GetProcedures ( ) { struct IScriptProcedureCollection * _result; HRESULT _hr = get_Procedures(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return IScriptProcedureCollectionPtr(_result, false); }
inline _bstr_t IScriptModule::GetName ( ) { BSTR _result; HRESULT _hr = get_Name(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _bstr_t(_result, false); }
inline IScriptProcedurePtr IScriptProcedureCollection::GetItem ( const _variant_t & Index ) { struct IScriptProcedure * _result; HRESULT _hr = get_Item(Index, &_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return IScriptProcedurePtr(_result, false); }
inline HRESULT IScriptControl::AddObject ( _bstr_t Name, IDispatch * Object, VARIANT_BOOL AddMembers ) { HRESULT _hr = raw_AddObject(Name, Object, AddMembers); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _hr; }
inline enum ScriptControlStates IScriptControl::GetState ( ) { enum ScriptControlStates _result; HRESULT _hr = get_State(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }
inline void IScriptControl::PutLanguage ( _bstr_t pbstrLanguage ) { HRESULT _hr = put_Language(pbstrLanguage); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); }
inline _bstr_t IScriptControl::GetLanguage ( ) { BSTR _result; HRESULT _hr = get_Language(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _bstr_t(_result, false); }
inline HRESULT IScriptError::Clear ( ) { HRESULT _hr = raw_Clear(); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _hr; }
inline long IScriptProcedure::GetNumArgs ( ) { long _result; HRESULT _hr = get_NumArgs(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }
inline long IScriptError::GetColumn ( ) { long _result; HRESULT _hr = get_Column(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }
inline _bstr_t IScriptError::GetDescription ( ) { BSTR _result; HRESULT _hr = get_Description(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _bstr_t(_result, false); }
inline void IScriptControl::PutUseSafeSubset ( VARIANT_BOOL pfUseSafeSubset ) { HRESULT _hr = put_UseSafeSubset(pfUseSafeSubset); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); }
inline IScriptErrorPtr IScriptControl::GetError ( ) { struct IScriptError * _result; HRESULT _hr = get_Error(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return IScriptErrorPtr(_result, false); }
inline void IScriptControl::PutState ( enum ScriptControlStates pssState ) { HRESULT _hr = put_State(pssState); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); }
inline HRESULT IScriptControl::Reset ( ) { HRESULT _hr = raw_Reset(); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _hr; }
inline void IScriptControl::PutSitehWnd ( long phwnd ) { HRESULT _hr = put_SitehWnd(phwnd); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); }
inline IUnknownPtr IScriptProcedureCollection::Get_NewEnum ( ) { IUnknown * _result; HRESULT _hr = get__NewEnum(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return IUnknownPtr(_result, false); }
inline long IScriptControl::GetTimeout ( ) { long _result; HRESULT _hr = get_Timeout(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }
inline long IScriptProcedureCollection::GetCount ( ) { long _result; HRESULT _hr = get_Count(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }
inline void IScriptControl::PutTimeout ( long plMilleseconds ) { HRESULT _hr = put_Timeout(plMilleseconds); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); }
inline IDispatchPtr IScriptModule::GetCodeObject ( ) { IDispatch * _result; HRESULT _hr = get_CodeObject(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return IDispatchPtr(_result, false); }
inline void IScriptControl::PutAllowUI ( VARIANT_BOOL pfAllowUI ) { HRESULT _hr = put_AllowUI(pfAllowUI); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); }
inline HRESULT IScriptModule::AddCode ( _bstr_t Code ) { HRESULT _hr = raw_AddCode(Code); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _hr; }
inline VARIANT_BOOL IScriptProcedure::GetHasReturnValue ( ) { VARIANT_BOOL _result; HRESULT _hr = get_HasReturnValue(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }
inline HRESULT IScriptModule::ExecuteStatement ( _bstr_t Statement ) { HRESULT _hr = raw_ExecuteStatement(Statement); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _hr; }
inline VARIANT_BOOL IScriptControl::GetUseSafeSubset ( ) { VARIANT_BOOL _result; HRESULT _hr = get_UseSafeSubset(&_result); if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); return _result; }