当前位置: 首页>>代码示例>>C++>>正文


C++ QAxObject::queryInterface方法代码示例

本文整理汇总了C++中QAxObject::queryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ QAxObject::queryInterface方法的具体用法?C++ QAxObject::queryInterface怎么用?C++ QAxObject::queryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAxObject的用法示例。


在下文中一共展示了QAxObject::queryInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadJS

void ReadiumJSApi::loadJS(QString jScript)
{

#if 0	
	QAxObject* doc = WebBrowser->querySubObject("Document()");
	//IDispatch* Disp;
	IDispatch* winDoc = NULL;
	IHTMLDocument2* document = NULL;

	//332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2
	//25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument
	doc->queryInterface(QUuid("{332C4425-26CB-11D0-B483-00C04FD90119}"), (void**)(&winDoc));
	if (winDoc) {
		document = NULL;
		winDoc->QueryInterface(IID_IHTMLDocument2, (void**)&document);
		IHTMLWindow2 *window = NULL;
		document->get_parentWindow(&window);
		QAxObject* documentWin = new QAxObject(document, WebBrowser);
		QAxObject* jScriptWin = new QAxObject(window, WebBrowser);
		//connect(jScriptWin, SIGNAL(exception(int, QString, QString, QString)), this, SLOT(printWinException(int, QString, QString, QString)));
		//jScriptInitialized = true;

		QVariantList params;
		//params.append(javaScript);
		//params.append("alert('Hi')");
		params.append("JScript");
		//QVariant result = jScriptWin->dynamicCall("execScript(QString, QString)", params);
		VARIANT var;
		QString strCode = jScript;
		QString stringLang("JScript");
		BSTR bstrCode = SysAllocString(strCode.toStdWString().c_str());
		BSTR bstrLang = SysAllocString(stringLang.toStdWString().c_str());
		window->execScript(bstrCode, bstrLang, &var);
		SysFreeString(bstrCode);
		SysFreeString(bstrLang);
		document->Release();
		winDoc->Release();
	}
	else {
		//qDebug() << "COULD NOT GET DOCUMENT OBJECT! Aborting";
	}
#else
	if (WebBrowser)
	{
		CComPtr<IDispatch> pDispDoc = WebBrowser->get_Document();
		CComQIPtr<IHTMLDocument2> pHtmlDoc(pDispDoc);
		if (pHtmlDoc)
		{
			CComPtr<IHTMLWindow2>    pMainWin2;
			pHtmlDoc->get_parentWindow(&pMainWin2);

			if (pMainWin2)
			{
				CComVariant    vtRv(0);
				CComBSTR bsCode = jScript.c_str() /*L"alert (\" Hi !\");"*/, bsLang = L"JavaScript";
				HRESULT hr = pMainWin2->execScript(bsCode, bsLang, &vtRv);

				if (!SUCCEEDED(hr))
				{
					//AfxMessageBox(L"Error executing script");
				}
			}
		}
	}


	//QAxObject* qv = WebBrowser->querySubObject("Document()");
	//QAxObject* qv1 = qv->querySubObject("parentWindow");
	//QString script = "(function(){" + jScript + "})()";
	//qDebug() << script;

	/*{
	QString filename = "Data.txt";
	QFile file(filename);
	if (file.open(QIODevice::ReadWrite)) {
	QTextStream stream(&file);
	stream << script << endl;
	}
	file.close();
	}*/

	//QVariantList params;
	//params.append("alert('hello')");
	//params.append("JScript");
	//QVariant result = qv1->dynamicCall("execScript(QString, QString)", params);
	//qv1->dynamicCall("execScript(Qstring)", script, "javascript");
	//qv1->dynamicCall("execScript(Qstring, QString)", script, "JScript");	//, "javascript"
	//qv1->deleteLater();
	//qv->deleteLater();

	//Log.i(TAG, "loadJS: "+jScript);
	//mJSLoader.loadJS("javascript:(function(){" + jScript + "})()");
	//pWebBrowser->dynamicCall(script);

#endif
}
开发者ID:GrayWolfMT,项目名称:SDKLauncher-Windows,代码行数:96,代码来源:CPP2JS.cpp


注:本文中的QAxObject::queryInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。