This is the code for implementing the "View Source" option in Internet Explorer void CMyBrowser::OnViewSource() { CWnd* pWnd = NULL; CWnd* pwndShell = m_WebBrowser2.GetWindow(GW_CHILD); // get the webbrowser window pointer if (pwndShell) { pWnd = pwndShell->GetWindow(GW_CHILD); //get the child window pointer }
if(pWnd != NULL) { WPARAM wParam = MAKELONG(IDM_VIEWSOURCE, 1); //convert to unsigned 32 bit value and pass it to WPARAM pWnd->SendMessage(WM_COMMAND, wParam, (LPARAM)pWndHTML->m_hWnd); //cool send a message to retreive the source. } } 是http://www.vckbase.com/document/上面的一篇文章啊
得到的Document是类,其结构不知道。
我感到奇怪,为什么大家都不去codeguru?多好的站点
void CMyHtmlView::OnSource()
{
IHTMLDocument2 doc;
HGLOBAL hMem = NULL;
LPSTREAM pStream = NULL;
IPersistStreamInit *pPersistStream = NULL;
ULARGE_INTEGER uli;
HRESULT hr;
doc=GetHtmlDocument();
hr = ptrDoc.QueryInterface(IID_IPersistStreamInit, &pPersistStream);
if(pPersistStream == NULL)
return;
if(FAILED(pPersistStream->GetSizeMax(&uli)))
{
pPersistStream->Release();
return;
}
uli.LowPart = 65536;
hMem = ::GlobalAlloc(GPTR, uli.LowPart);
if(hMem == NULL)
{
pPersistStream->Release();
return;
} hr = ::CreateStreamOnHGlobal(hMem, TRUE, &pStream);
if(FAILED(hr))
{
pPersistStream->Release();
::GlobalFree(hMem);
return;
}
hr = pPersistStream->Save(pStream, TRUE);
AfxMessageBox((LPCTSTR)hMem);
::GlobalUnlock(hMem);
::GlobalFree(hMem);
hr = pPersistStream->Release();
pStream->Release();
}
void CMyBrowser::OnViewSource()
{
CWnd* pWnd = NULL; CWnd* pwndShell = m_WebBrowser2.GetWindow(GW_CHILD); // get the webbrowser window pointer if (pwndShell)
{
pWnd = pwndShell->GetWindow(GW_CHILD); //get the child window pointer
}
if(pWnd != NULL)
{
WPARAM wParam = MAKELONG(IDM_VIEWSOURCE, 1); //convert to unsigned 32 bit value and pass it to WPARAM
pWnd->SendMessage(WM_COMMAND, wParam, (LPARAM)pWndHTML->m_hWnd); //cool send a message to retreive the source.
}
}
是http://www.vckbase.com/document/上面的一篇文章啊