www.pudn.com > WebBrowse.rar > WebBrowseView.cpp


// WebBrowseView.cpp : implementation of the CWebBrowseView class 
// 
 
#include "stdafx.h" 
#include "WebBrowse.h" 
#include "WebBrowseDoc.h" 
#include "WebBrowseView.h" 
 
#include "MainFrm.h" 
extern CWebBrowseApp theApp; 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CWebBrowseView 
 
IMPLEMENT_DYNCREATE(CWebBrowseView, CHtmlView) 
 
BEGIN_MESSAGE_MAP(CWebBrowseView, CHtmlView) 
	//{{AFX_MSG_MAP(CWebBrowseView) 
	ON_COMMAND(ID_HOME, OnHome) 
	ON_COMMAND(ID_REFRESH, OnRefresh) 
	ON_COMMAND(ID_BACK, OnBack) 
	ON_COMMAND(ID_FORWARD, OnForward) 
	ON_COMMAND(ID_STOP, OnStop) 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CHtmlView::OnFilePrint) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CWebBrowseView construction/destruction 
 
CWebBrowseView::CWebBrowseView() 
{ 
	// TODO: add construction code here 
 
} 
 
CWebBrowseView::~CWebBrowseView() 
{ 
} 
 
BOOL CWebBrowseView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CHtmlView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CWebBrowseView drawing 
 
void CWebBrowseView::OnDraw(CDC* pDC) 
{ 
	CWebBrowseDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
} 
 
void CWebBrowseView::OnInitialUpdate() 
{ 
	CHtmlView::OnInitialUpdate(); 
	// TODO: This code navigates to a popular spot on the web. 
	//  change the code to go where you'd like. 
	// 打开默认主页 
	GoHome(); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CWebBrowseView printing 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CWebBrowseView diagnostics 
 
#ifdef _DEBUG 
void CWebBrowseView::AssertValid() const 
{ 
	CHtmlView::AssertValid(); 
} 
 
void CWebBrowseView::Dump(CDumpContext& dc) const 
{ 
	CHtmlView::Dump(dc); 
} 
 
CWebBrowseDoc* CWebBrowseView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWebBrowseDoc))); 
	return (CWebBrowseDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CWebBrowseView message handlers 
 
void CWebBrowseView::OnHome()  
{ 
	// TODO: Add your command handler code here 
	GoHome(); 
} 
 
void CWebBrowseView::OnRefresh()  
{ 
	// TODO: Add your command handler code here 
	char szAdd[255]; 
	CMainFrame* pFrame = (CMainFrame*) theApp.GetMainWnd(); 
	// 获得地址 
	pFrame->m_wndAddressBar.m_EditAddress.GetWindowText(szAdd,255);  
	Navigate(szAdd); 
} 
 
void CWebBrowseView::OnBack()  
{ 
	// TODO: Add your command handler code here 
	GoBack(); 
} 
 
void CWebBrowseView::OnForward()  
{ 
	// TODO: Add your command handler code here 
	GoForward(); 
} 
 
void CWebBrowseView::OnStop()  
{ 
	// TODO: Add your command handler code here 
	Stop(); 
} 
 
 
void CWebBrowseView::OnNavigateComplete2(LPCTSTR strURL)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	CMainFrame* pFrame = (CMainFrame*) theApp.GetMainWnd(); 
	// 获得地址 
	pFrame->m_wndAddressBar.m_EditAddress.SetWindowText(strURL);  
 
	CHtmlView::OnNavigateComplete2(strURL); 
}