當前位置:編程學習大全網 - 源碼下載 - 怎樣得到有框架的全部頁面源代碼

怎樣得到有框架的全部頁面源代碼

用chtmlview打開的帶框架的網頁,寫了下面的函數,

BOOL CHtmlView::GetFrameSource( IDispatch *pDisp, CString& refString )

{

BOOL bRetVal = FALSE;

HRESULT hr = S_OK;

if ( pDisp != NULL )

{

CComQIPtr<IWebBrowser2> pBrowser = pDisp;

if ( pBrowser != NULL )

{

IDispatch *pDispDoc = NULL;

hr = pBrowser->get_Document(&pDispDoc);

if ( !( FAILED(hr) || !pDisp ) )

{

CComQIPtr<IPersistStreamInit> pStmInit = pDisp;

if ( !pStmInit )

{

HGLOBAL hMemory;

hMemory = GlobalAlloc(GMEM_MOVEABLE, 0);

if (hMemory != NULL)

{

CComQIPtr<IPersistStreamInit> spPSI = pDispDoc;

if( spPSI != NULL)

{

CComPtr<IStream> spStream;

if (SUCCEEDED(CreateStreamOnHGlobal(hMemory, TRUE, &spStream)))

{

spPSI->Save(spStream, FALSE);

LPCTSTR pstr = (LPCTSTR) GlobalLock(hMemory);

if (pstr != NULL)

{

// Stream is always ANSI, but CString

// assignment operator will convert implicitly.

bRetVal = TRUE;

TRY

{

refString = pstr;

}

CATCH_ALL(e)

{

bRetVal = FALSE;

DELETE_EXCEPTION(e);

}

END_CATCH_ALL

if(bRetVal == FALSE)

GlobalFree(hMemory);

else

GlobalUnlock(hMemory);

}

}

}

}

}

}

RELEASE(pDispDoc);

}

}

return bRetVal;

}

但是只能用在DocumentComplete裏,因為我不知道怎麽獲得pDisp,好像只有在DocumentComplete裏才能獲得框架各頁的pDisp,這樣沒有通用性,我想要實現的是像GetSource壹樣的功能,就是只要網頁下載完畢,就可以在任意時刻獲得框架html源文件

  • 上一篇:請高手把通信達技術指標修改為條件選股指標可以預警用
  • 下一篇:thinkphp中的commond這個方法是幹什麽用的,參數怎麽寫
  • copyright 2024編程學習大全網