⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myhtmlview.cpp

📁 Displaying Multiple Views in IE
💻 CPP
字号:
/**************************************************************************
   THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
   ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
   PARTICULAR PURPOSE.
   Author: Barretto VN  7/2002
**************************************************************************/

// MyHTMLView.cpp : implementation file
//

#include "stdafx.h"
#include "FavsMV.h"
#include "MyHTMLView.h"

#include "FavsMVDoc.h"
#include "FullScreenMode.h"

#include "MainFrm.h"

#include "OpenDLg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyHTMLView

IMPLEMENT_DYNCREATE(CMyHTMLView, CView)

CMyHTMLView::CMyHTMLView()
{
	bControlsCreated = FALSE;
	bURLRetreived=FALSE;
}

CMyHTMLView::~CMyHTMLView()
{
}

BEGIN_MESSAGE_MAP(CMyHTMLView, CView)
	//{{AFX_MSG_MAP(CMyHTMLView)
	ON_WM_SIZE()
	ON_COMMAND(ID_FULL_SCREEN, OnFullScreen)
	ON_UPDATE_COMMAND_UI(ID_FULL_SCREEN, OnUpdateFullScreen)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_WM_CREATE()
	ON_COMMAND(ID_STOP_CURRENT, OnStopCurrent)
	ON_UPDATE_COMMAND_UI(ID_STOP_CURRENT, OnUpdateStopCurrent)
     
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyHTMLView drawing

void CMyHTMLView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CMyHTMLView diagnostics

#ifdef _DEBUG
void CMyHTMLView::AssertValid() const
{
	CView::AssertValid();
}

void CMyHTMLView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyHTMLView message handlers

void CMyHTMLView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
   CFavsMVDoc* pDoc = (CFavsMVDoc*)GetDocument();
   pDoc->m_HTMLView = this;
}

void CMyHTMLView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if(	bControlsCreated)
	{
		m_SiteNameBar.MoveWindow(-1,-1, cx+2, 20);
		m_WebBrowser.MoveWindow(-1,18,cx+2,cy-17);
		m_WebBrowser.UpdateWindow();
	}

}

void CMyHTMLView::NavigateTheURL(CString url)
{

	CString siteName = url.Mid(url.Find("//", 0)+2);
	siteName = siteName.Left(siteName.Find("/",0));

	m_SiteNameBar.SetWindowText(siteName);
	m_WebBrowser.Navigate(url, NULL, NULL, NULL, NULL);
	bURLRetreived = TRUE;
}

void CMyHTMLView::OnFullScreen() 
{
	CFullScreenMode* dlg = new CFullScreenMode;
	dlg->m_URL = m_WebBrowser.GetLocationURL();
	dlg->DoModal();	
}

void CMyHTMLView::OnUpdateFullScreen(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(bURLRetreived);	
}

void CMyHTMLView::OnFileOpen() 
{
	// TODO: Add your command handler code here
	COpenDLg* dlg = new COpenDLg;
	if(dlg->DoModal() == IDCANCEL)
		return;

	if(dlg->m_URL != "")
		NavigateTheURL(dlg->m_URL);
}

int CMyHTMLView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here

   LOGFONT lf;
   memset(&lf, 0, sizeof(LOGFONT));   // Clear out structure.
   lf.lfHeight = 12;                  // Request a 20-pixel-high font
   strcpy(lf.lfFaceName, "MS SANS SERIF");    //    with face name "Arial".
   m_font.CreateFontIndirect(&lf);    // Create the font.

	m_SiteNameBar.Create("", WS_DLGFRAME|WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this , 0xffff);
	m_SiteNameBar.SetFont(&m_font);
	m_WebBrowser.Create("", WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, IDC_EXPLORER, NULL, FALSE);
	bControlsCreated = TRUE;
	
	return 0;
}

void CMyHTMLView::OnStopCurrent() 
{
	// TODO: Add your command handler code here
	m_WebBrowser.Stop();	
}

void CMyHTMLView::OnUpdateStopCurrent(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable(!bURLRetreived);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -