// 웹페이지에 있는 javascript 함수를 호출한다.
m_pIWeb = GetIWebPointer();
IDispatch *pDisp=NULL;
VARIANT varRet;
m_pIWeb->get_Document(&pDisp);
IHTMLDocument2* pHtmlDoc = (IHTMLDocument2*)pDisp;
IHTMLWindow2* pHtml;
pHtmlDoc->get_parentWindow(&pHtml);
CString sFunc = "func_control_call();";
BSTR pbFunc = sFunc.AllocSysString();
CString sLang = "javascript";
BSTR pbLang = sLang.AllocSysString();
pHtml->execScript(pbFunc, pbLang, &varRet);
pDisp->Release();
// ------------------------------------------------------------
IWebBrowser2* CClockCtrl::GetIWebPointer() // 브라우저 포인터 얻기.
{
HRESULT hr ;
IOleContainer *pIContainer = NULL ;
IWebBrowser2 *pIWeb = NULL ;
IServiceProvider *pISP = NULL ;
// Get IOleClientSite interface pointer.
LPOLECLIENTSITE pIClientSite = GetClientSite() ;
// Get IOleContainer interface poineter.
hr = pIClientSite->GetContainer(&pIContainer) ;
if (hr != S_OK) {
pIClientSite->Release() ;
return NULL ;
}
// Get IServiceProvider interface pointer.
hr = pIClientSite->QueryInterface(IID_IServiceProvider,
(void **)&pISP) ;
if (hr != S_OK) {
pIContainer->Release() ;
pIClientSite->Release() ;
return NULL ;
}
// Get IWebBrowser2 interface pointer.
hr = pISP->QueryService(IID_IWebBrowserApp,
IID_IWebBrowser2,(void**)&pIWeb) ;
if (hr != S_OK) {
pIContainer->Release() ;
pIClientSite->Release() ;
pISP->Release() ;
return NULL ;
}
// release interface.
pIContainer->Release() ;
pIClientSite->Release() ;
pISP->Release() ;
return pIWeb ;
}
m_pIWeb = GetIWebPointer();
IDispatch *pDisp=NULL;
VARIANT varRet;
m_pIWeb->get_Document(&pDisp);
IHTMLDocument2* pHtmlDoc = (IHTMLDocument2*)pDisp;
IHTMLWindow2* pHtml;
pHtmlDoc->get_parentWindow(&pHtml);
CString sFunc = "func_control_call();";
BSTR pbFunc = sFunc.AllocSysString();
CString sLang = "javascript";
BSTR pbLang = sLang.AllocSysString();
pHtml->execScript(pbFunc, pbLang, &varRet);
pDisp->Release();
// ------------------------------------------------------------
IWebBrowser2* CClockCtrl::GetIWebPointer() // 브라우저 포인터 얻기.
{
HRESULT hr ;
IOleContainer *pIContainer = NULL ;
IWebBrowser2 *pIWeb = NULL ;
IServiceProvider *pISP = NULL ;
// Get IOleClientSite interface pointer.
LPOLECLIENTSITE pIClientSite = GetClientSite() ;
// Get IOleContainer interface poineter.
hr = pIClientSite->GetContainer(&pIContainer) ;
if (hr != S_OK) {
pIClientSite->Release() ;
return NULL ;
}
// Get IServiceProvider interface pointer.
hr = pIClientSite->QueryInterface(IID_IServiceProvider,
(void **)&pISP) ;
if (hr != S_OK) {
pIContainer->Release() ;
pIClientSite->Release() ;
return NULL ;
}
// Get IWebBrowser2 interface pointer.
hr = pISP->QueryService(IID_IWebBrowserApp,
IID_IWebBrowser2,(void**)&pIWeb) ;
if (hr != S_OK) {
pIContainer->Release() ;
pIClientSite->Release() ;
pISP->Release() ;
return NULL ;
}
// release interface.
pIContainer->Release() ;
pIClientSite->Release() ;
pISP->Release() ;
return pIWeb ;
}
'Program Visual C++' 카테고리의 다른 글
GetPrivateProfileString() WritePrivateProfileString() (0) | 2007.04.03 |
---|---|
Invoke 오버라이드 (0) | 2007.03.29 |
IHTMLDocument2 에서 IWebBrowser2 인터페이스 구하기... | (0) | 2007.03.29 |
Screen Saver를 동작 못하게 함. (0) | 2007.03.22 |
Visual C++ Release 디버깅2 (0) | 2007.02.28 |