Implementing the “View Source” option in Internet Explorer

.

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.
	}
}

Updated on May 23 1998

More by Author

Must Read