int GetAppLanguage(IVApplicationPtr app) { long app_language = 0; if (FAILED(app->get_Language(&app_language))) return DEFAULT_LANGUAGE; CComVariant v_disp_language_settings; CComDispatchDriver disp = app; if (SUCCEEDED(disp.GetPropertyByName(L"LanguageSettings", &v_disp_language_settings))) { Office::LanguageSettingsPtr language_settings; if (SUCCEEDED(V_DISPATCH(&v_disp_language_settings)->QueryInterface(__uuidof(Office::LanguageSettings), (void**)&language_settings))) { int ui_language = app_language; if (SUCCEEDED(language_settings->get_LanguageID(Office::msoLanguageIDUI, &ui_language))) app_language = ui_language; } } switch (app_language) { case 1033: case 1031: case 1049: return app_language; } return DEFAULT_LANGUAGE; }
void CBoxHttpHost::CallEvent(LPCWSTR strEvent, CBoxHttpContext *pContext, CBoxHttpSession *pSession, BOOL bAddHost) { CBoxObject<CBoxScriptObject> pScriptObject; CBoxObject<CBoxHttpContext> pNullContext; CComDispatchDriver pDisp; pScriptObject.CreateInstance(); if(pScriptObject->Load(m_strEventSink) != 0) return; if(pContext)pContext->Bind(NULL, pScriptObject); else { pNullContext.CreateInstance(); pNullContext->m_strBasePath = m_strRoot; pScriptObject->AddNameItem(_T("Server"), pNullContext->GetIDispatch(FALSE)); pScriptObject->AddNameItem(_T("Application"), m_pApplication); } if(pSession)pScriptObject->AddNameItem(_T("Session"), pSession->GetIDispatch(FALSE)); if(bAddHost)pScriptObject->AddNameItem(_T("Host"), GetIDispatch(FALSE)); if(pScriptObject->Init() != 0) return; pDisp.Attach(pScriptObject->get_Object()); if(pDisp) { pDisp.Invoke0(strEvent); theApp.m_pSystem->ClearLock(); } }
void CPluginsDialog::SaveCmds() { CString dir = L"data"; CreateDirectory(dir,NULL); dir += L"/"; dir += _plugins->name().c_str(); CreateDirectory(dir,NULL); CComDispatchDriver spScript; if(S_OK != m_spHtmlDoc->get_Script(&spScript)) { return; } CComVariant varRet; if(S_OK != spScript.Invoke0(L"get_cmds", &varRet)) { return; } CString str = varRet; std::string utf8 = dark::windows::utf::to_utf8(str.GetBuffer()); std::ofstream outf(dir + L"/cmds.json",std::ios::binary | std::ios::trunc | std::ios::out); if(outf.is_open()) { outf.write(utf8.data(),utf8.size()); } }
void CPluginsDialog::CallJsSetFocus() { CComDispatchDriver spScript; if(S_OK != m_spHtmlDoc->get_Script(&spScript)) { return; } spScript.Invoke0(L"set_focus"); }
void CPluginsDialog::CallJsShowMsg(const std::wstring& msg,const std::wstring& cmd,std::size_t showcode) { CComDispatchDriver spScript; if(S_OK != m_spHtmlDoc->get_Script(&spScript)) { return; } CComVariant params[3] = {showcode, cmd.c_str(), msg.c_str() }; spScript.InvokeN(L"show_msg",params,3); }
LRESULT CIncrementSystemBFDlg::OnMyClickMessage(WPARAM wParam, LPARAM lParam) { CComDispatchDriver spScript; IDispatch * pDocDisp = NULL; IHTMLDocument2 *pDoc=NULL; pDocDisp = m_MyIE.GetDocument(); if (pDocDisp != NULL) { // Obtained the document object by specifying the IHTMLDocument2 Interface. HRESULT hr= pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc ); pDoc->get_Script(&spScript); CComVariant varRet; spScript.Invoke0(L"NoticeClient", &varRet); CComDispatchDriver spData = varRet.pdispVal; CComVariant varValue1; spData.GetPropertyByName(L"phone", &varValue1); CString strResult = _com_util::ConvertBSTRToString((_bstr_t)varValue1); szCharUrl.Format("%s%s", cUrls.QueryPhone, strResult); //szCharUrl.Format("http://www.baidu.com/s?wd=%s", strResult); //szCharUrl.Format("http://132.90.101.25:7001/portal"); //szCharUrl.Format("http://132.77.51.11:7700/salemanm/salemanm?service=page/silverservice.silverJobExec.goldUnfinishedFrame&listener=initFrame&PROVINCEID=0011&STAFF_ID=yujp21&PASSWORD=H3B5VVJk0JFroCYwhWHbA9C8yes=&LOGIN_TYPE=KFSYS&inModeCode=1&cond_CONFIG=job&cond_FLAG=all&closeNavMethod=close&JOB_STATUS=1&VALID_FLAG=1&EPARCHY_CODE=0010&SERVER_NUMBER=18612452378"); CString sResult(_T("")); // http://132.77.220.134:8081/window/servlet/CheckSerialNumber?serial_number=132.77.220.134 //CString ip(tempUrl.Left(pos).rig); HttpRequestGet("132.77.220.134", 8081, "window/servlet/CheckSerialNumber?serial_number="+strResult, sResult); ///m_MyIE.Navigate(szCharUrl, NULL, NULL, NULL, NULL); //PostMessage(WM_SIZE,0,0); } return 1; }
bool AutoProcessor::process(const char *in_str, string &out_str) { if (!bInit) return false; CComBSTR str(in_str); CComVariant vArg(str); CComVariant vRes; HRESULT hResult = disp.Invoke1(L"Process", &vArg, &vRes); if (FAILED(hResult)) return false; CComBSTR out(vRes.bstrVal); if (out.Length()){ size_t size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), 0, 0, NULL, NULL); char *res = new char[size + 1]; size = WideCharToMultiByte(CP_ACP, 0, out, wcslen(out), res, size, NULL, NULL); res[size] = 0; out_str = res; delete[] res; }else{ return false; } return true; }
///////////////////////////////////////////////////////////////////////////// // CMaxMaterialCollection STDMETHODIMP CMaxMaterialCollection::FinalConstruct() { HRESULT hr = E_FAIL, hr2 = E_FAIL; //simply make a reference to the scene material collection MtlBaseLib* pMtlLib = GetCOREInterface()->GetSceneMtls(); mLastSceneMtlLibSize = 0; #ifdef PERSIST_SCRATCH mpScratchMtlLib = NULL; #endif assert(pMtlLib); //RK: 10/21/04 -- this forces ACT toolkit to initialize at startup and avoids delays during material assignment. CComDispatchDriver act; /* FIXME: Use the .NET wrappers directly instead of this; act.CoCreateInstance( L"Autodesk.Act.Core.ContentSerializer" ); For some reason, the prog ID above is not being registered with the version we now install with Max 9, and I've had to resort to using the CLSID directly. Either we have the wrong version, or the new DLL just doesn't register its prog ID. (more likely it's the former) */ CLSID clsidCore; hr = CLSIDFromString(L"{978C551B-5919-42F7-81AB-690D66AB7B78}", &clsidCore); if( SUCCEEDED(hr) ) hr = act.CoCreateInstance( clsidCore ); if (SUCCEEDED(hr)) { CComVariant xml(L"<Material><StandardMtl name=\"Test\" /></Material>"); CComPtr<IUnknown> mtl; hr2 = mtl.CoCreateInstance( L"Autodesk.Act.Content.Material"); hr2 = act.Invoke1( L"DeserializeString", &xml ); } if ( FAILED(hr) || FAILED(hr2) ) { if (GetCOREInterface()->GetQuietMode()) GetCOREInterface()->Log()->LogEntry(SYSLOG_ERROR,NO_DIALOG, TSTR(GetString(IDS_PROJNAME)), TSTR(GetString(IDS_ACT_REGISTRATION_FAILED))); else MaxMsgBox( GetCOREInterface()->GetMAXHWnd(), TSTR(GetString(IDS_ACT_REGISTRATION_FAILED)), TSTR(GetString(IDS_PROJNAME)), MB_OK ); } assert(SUCCEEDED(hr) && SUCCEEDED(hr2)); //RK: This forces XMlmtl to initialize at startup. CComPtr<IVIZPointerClient> pPointerClient; hr = GetXMLImpExp(&pPointerClient); assert(SUCCEEDED(hr)); #ifdef RECYCLE_MATS #endif RegisterNotification(NotifyProc, this, NOTIFY_FILE_PRE_OPEN); RegisterNotification(NotifyProc, this, NOTIFY_FILE_POST_OPEN); RegisterNotification(NotifyProc, this, NOTIFY_FILE_OPEN_FAILED); RegisterNotification(NotifyProc, this, NOTIFY_FILE_PRE_MERGE); RegisterNotification(NotifyProc, this, NOTIFY_FILE_POST_MERGE); RegisterNotification(NotifyProc, this, NOTIFY_FILE_PRE_SAVE); RegisterNotification(NotifyProc, this, NOTIFY_FILE_POST_SAVE); RegisterNotification(NotifyProc, this, NOTIFY_PRE_IMPORT); RegisterNotification(NotifyProc, this, NOTIFY_POST_IMPORT); RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_PRE_NEW); RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_POST_NEW); RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_PRE_RESET); RegisterNotification(NotifyProc, this, NOTIFY_SYSTEM_POST_RESET); RegisterNotification(NotifyProc, this, NOTIFY_SCENE_UNDO); RegisterNotification(NotifyProc, this, NOTIFY_SCENE_REDO); #ifdef SUSPEND_UNDO RegisterNotification(NotifyProc, this, NOTIFY_SCENE_PRE_UNDO); RegisterNotification(NotifyProc, this, NOTIFY_SCENE_PRE_REDO); #endif RegisterNotification(NotifyProc, (void *)this, NOTIFY_MEDIT_SHOW); #ifdef TP_SUSPEND_FOR_FILELINK RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_BIND ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_BIND ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_DETACH ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_DETACH ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_RELOAD ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_RELOAD ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_PRE_ATTACH ); RegisterNotification(NotifyProc, this, NOTIFY_FILELINK_POST_ATTACH ); #endif //and finally a mechanism for other parts of the system to actively suspend TP RegisterNotification(NotifyProc, this, NOTIFY_TOOLPALETTE_MTL_SUSPEND ); RegisterNotification(NotifyProc, this, NOTIFY_TOOLPALETTE_MTL_RESUME ); //for DID 642266, pre and post cloning RegisterNotification(NotifyProc, this, NOTIFY_PRE_NODES_CLONED ); RegisterNotification(NotifyProc, this, NOTIFY_POST_NODES_CLONED ); RefResult res = ReplaceReference(SCENE_MTLLIB_REFNUM, (RefTargetHandle) pMtlLib); #ifdef PERSIST_SCRATCH res = ReplaceReference(SCRATCH_MTLLIB_REFNUM, (RefTargetHandle) &theScratchMtlLib); #endif Resume(); if(res == REF_SUCCEED) hr = S_OK; return hr; }
CComQIPtr<IHTMLElement> WebHandler::GetElement( CComQIPtr<IHTMLElementCollection> spElementCollection, const std::wstring& attrName, const std::wstring& attrValue, const std::wstring& textValue) { long nItemCount = 0; //取得表单数目 HRESULT hr = spElementCollection->get_length(&nItemCount); if (FAILED(hr)) return CComQIPtr<IHTMLElement>(); for (long i = 0; i < nItemCount; i++) { CComDispatchDriver spDisp; //取得第 j 项表单域 hr = spElementCollection->item(CComVariant(i), CComVariant(), &spDisp); if (FAILED(hr)) continue; CComQIPtr<IHTMLElement> spElement = spDisp; if (!spElement) break; bool bFind = false; std::wstring compareStr; if (attrName == L"class") { CComBSTR className; hr = spElement->get_className(&className); if (!FAILED(hr) && className) { compareStr = (LPCTSTR)className; } } else { CComVariant vtAttr; hr = spDisp.GetPropertyByName(attrName.c_str(), &vtAttr); if (!FAILED(hr) && (vtAttr.vt == VT_BSTR) && (NULL != vtAttr.bstrVal)) { compareStr = (LPCTSTR)vtAttr.bstrVal; } } if (!compareStr.empty() && (compareStr.compare(attrValue) == 0)) { if (textValue.empty()) { bFind = true; } else { CComBSTR innerText; hr = spElement->get_innerText(&innerText); if (!FAILED(hr) && innerText) { if ((textValue.compare((LPCTSTR)innerText) == 0)) { bFind = true; } } } } else { continue; } if (bFind) { return spElement; } } return CComQIPtr<IHTMLElement>(); }
void EnumForms(IHTMLDocument2 *pIHTMLDocument2) { if(!pIHTMLDocument2) return; HRESULT hr; USES_CONVERSION; CComQIPtr< IHTMLElementCollection > spElementCollection; hr = pIHTMLDocument2->get_forms(&spElementCollection); //取得表单集合 if (FAILED(hr)) { cout << _T("错误: 获取Form集合IHTMLElementCollection!") << endl; return; } long nFormCount = 0; //取得表单数目 hr = spElementCollection->get_length(&nFormCount); if (FAILED(hr)) { cout << _T("错误: 获取Form集合IHTMLElementCollection的长度!") << endl; return; } cout << "Form对象共: " << nFormCount << endl; for(long i = 0; i < nFormCount; i++) { IDispatch *pDisp = NULL; //取得第i个Form表单 hr = spElementCollection->item(CComVariant(i), CComVariant(), &pDisp); if (FAILED(hr)) continue; CComQIPtr< IHTMLFormElement > spFormElement = pDisp; pDisp->Release(); long nElemCount = 0; //取得表单中域的数目 hr = spFormElement->get_length(&nElemCount); if (FAILED(hr)) continue; for(long j = 0; j < nElemCount; j++) { CComDispatchDriver spInputElement; //取得第 j 项表单域 hr = spFormElement->item(CComVariant(j), CComVariant(), &spInputElement); if (FAILED(hr)) continue; CComVariant vName,vVal,vType; //取得表单域的 名,值,类型 hr = spInputElement.GetPropertyByName(L"name", &vName); if(FAILED(hr)) continue; hr = spInputElement.GetPropertyByName(L"value", &vVal); if(FAILED(hr)) continue; hr = spInputElement.GetPropertyByName(L"type", &vType); if(FAILED(hr)) continue; cout << _T("[") << (vType.bstrVal? OLE2CT(vType.bstrVal) : _T("")) << _T("] ") << (vName.bstrVal? OLE2CT(vName.bstrVal) : _T("")) << _T(" = ") << (vVal.bstrVal? OLE2CT(vVal.bstrVal ) : _T("")) << endl; } //想提交这个表单吗?删除下面语句的注释吧 //pForm->submit(); } }