📄 ie6mdiview.cpp
字号:
// IE6mdiView.cpp : implementation of the CIE6mdiView class
//
#include "stdafx.h"
#include "IE6mdi.h"
#include "IE6mdiDoc.h"
#include "IE6mdiView.h"
#include "MainFrm.h"
#include "ViewManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIE6mdiView
IMPLEMENT_DYNCREATE(CIE6mdiView, CView)
BEGIN_MESSAGE_MAP(CIE6mdiView, CView)
//{{AFX_MSG_MAP(CIE6mdiView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_COMMAND(ID_PRINT, OnPrint)
ON_COMMAND(ID_GO_BACK, OnGoBack)
ON_COMMAND(ID_GO_FORWARD, OnGoForward)
ON_COMMAND(ID_GO_START_PAGE, OnGoStartPage)
ON_COMMAND(ID_VIEW_STOP, OnViewStop)
ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_WM_DESTROY()
ON_COMMAND(ID_KILL_ALL, OnKillAll)
ON_WM_PAINT()
ON_WM_TIMER()
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
ON_COMMAND(ID_EDIT_SELECTALL, OnEditSelectall)
ON_COMMAND(ID_POPUP_WINDOW, OnWindowNopopupwindow)
ON_COMMAND(ID_POPUP_WINDOW_OFF, OnWindowNopopupwindow)
ON_COMMAND(ID_VIEW_FONTS_LARGEST, OnViewFontsLargest)
ON_COMMAND(ID_VIEW_FONTS_LARGE, OnViewFontsLarge)
ON_COMMAND(ID_VIEW_FONTS_MEDIUM, OnViewFontsMedium)
ON_COMMAND(ID_VIEW_FONTS_SMALL, OnViewFontsSmall)
ON_COMMAND(ID_VIEW_FONTS_SMALLEST, OnViewFontsSmallest)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIE6mdiView construction/destruction
CIE6mdiView::CIE6mdiView()
{
LookingURL = 0;
m_iActivated = 1;
m_iNoPosition = 1; // no m_pos valid !
theViewManager.AddView("", this);
m_iPopupWindow = AfxGetApp()->GetProfileInt("Settings","NoPopupWindow",1);
}
CIE6mdiView::~CIE6mdiView()
{
theViewManager.RemoveView(this);
}
BOOL CIE6mdiView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CIE6mdiView drawing
void CIE6mdiView::OnDraw(CDC* pDC)
{
CIE6mdiDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
/////////////////////////////////////////////////////////////////////////////
// CIE6mdiView diagnostics
#ifdef _DEBUG
void CIE6mdiView::AssertValid() const
{
CView::AssertValid();
}
void CIE6mdiView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CIE6mdiDoc* CIE6mdiView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CIE6mdiDoc)));
return (CIE6mdiDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CIE6mdiView message handlers
int CIE6mdiView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
/*
*******************************************************************************/
// FUNCTION : void CIE6mdiView::OnFileOpen()
//
// PURPOSE : good question, I think it's not used anymore... :O)
//
// PARAMETERS : none
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CIE6mdiView::OnFileOpen()
{
CString str;
str.LoadString(IDS_FILETYPES);
CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, str);
if(fileDlg.DoModal() == IDOK)
Navigate2(fileDlg.GetPathName(), 0, NULL);
}
// these are all simple one-liners to do simple controlling of the browser
void CIE6mdiView::OnGoBack()
{
GoBack();
}
void CIE6mdiView::OnGoForward()
{
GoForward();
}
void CIE6mdiView::OnGoStartPage()
{
GoHome();
}
void CIE6mdiView::OnViewStop()
{
Stop();
CMDIChildWnd* m_pChild=((CMDIChildWnd*)GetParentFrame());
if (m_iActivated)
((CMainFrame*)(m_pChild->GetMDIFrame()))->StopAnimation();
LookingURL = 0;
}
void CIE6mdiView::OnViewRefresh()
{
Refresh2(REFRESH_COMPLETELY); // "pragma:nocache" sent
// I cannot use StartAnimation because the end of a refresh does not
// fire any event (no OnDocumentDone !!!)
}
void CIE6mdiView::OnSize(UINT nType, int cx, int cy)
{
CHtmlView::OnSize(nType, cx, cy);
}
/*
*******************************************************************************/
// FUNCTION : void CIE6mdiView::OnDocumentComplete(LPCTSTR)
//
// PURPOSE : download complete. Stop the AVI and refresh the address bar
//
// PARAMETERS :
// lpszUrl - URL
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CIE6mdiView::OnDocumentComplete(LPCTSTR lpszUrl)
{
CMDIChildWnd* m_pChild=((CMDIChildWnd*)GetParentFrame());
CMainFrame* m_pFrame=((CMainFrame*)(m_pChild->GetMDIFrame()));
// make sure the main frame has the new URL. This call also stops the animation
// be sure we are active !!!
if (m_iActivated) {
m_pFrame->SetAddress(GetLocationURL());
m_pFrame->StopAnimation();
}
LookingURL = 0;
}
void CIE6mdiView::OnInitialUpdate()
{
CView::OnInitialUpdate();
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
if (m_iPopupWindow == 1) {
pFrame->m_wndToolBar.SetButtonInfo(8, ID_POPUP_WINDOW_OFF, TBSTYLE_BUTTON, 14);
}
else {
pFrame->m_wndToolBar.SetButtonInfo(8, ID_POPUP_WINDOW, TBSTYLE_BUTTON, 13);
}
CIE6mdiDoc * pDoc = GetDocument();
CString cs = pDoc->GetTitle();
theViewManager.SetViewName(cs, this);
CHtmlView::OnInitialUpdate();
GoHome();
}
/*
*******************************************************************************/
// FUNCTION : void CIE6mdiView::OnBeforeNavigate2(LPCTSTR,DWORD,LPCTSTR,CByteArray&,LPCTSTR,BOOL*)
//
// PURPOSE : start the AVI animation
//
// PARAMETERS :
// lpszURL -
// nFlags -
// lpszTargetFrameName -
// baPostedData -
// lpszHeaders -
// pbCancel -
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CIE6mdiView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags,
LPCTSTR lpszTargetFrameName,
CByteArray& baPostedData,
LPCTSTR lpszHeaders, BOOL* pbCancel)
{
// start the animation so that is plays while the new page is being loaded
LookingURL = 1;
if (m_iActivated) {
CMDIChildWnd* m_pChild=((CMDIChildWnd*)GetParentFrame());
((CMainFrame*)(m_pChild->GetMDIFrame()))->StartAnimation();
}
}
/*
*******************************************************************************/
// FUNCTION : void CIE6mdiView::OnTitleChange(LPCTSTR)
//
// PURPOSE : update the main frame's title bar and the URL of the view
// in the URL list
//
// PARAMETERS :
// lpszText - the new title
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CIE6mdiView::OnTitleChange(LPCTSTR lpszText)
{
// this will change the main frame's title bar
if (m_pDocument != NULL)
m_pDocument->SetTitle(lpszText);
theViewManager.SetViewName(lpszText, this);
// add the current URL to the list of URL's
CMDIChildWnd* m_pChild=((CMDIChildWnd*)GetParentFrame());
CMainFrame* m_pFrame=((CMainFrame*)(m_pChild->GetMDIFrame()));
if (m_iNoPosition == 1) {
// first call !
m_pos = m_pFrame->GetFreePos();
if (m_pos == NULL)
m_pos = m_pFrame->m_lUrl.AddTail(GetLocationURL());
else
m_pFrame->m_lUrl.SetAt(m_pos,GetLocationURL());
}
else {
if (!m_pFrame->m_lUrl.IsEmpty())
m_pFrame->m_lUrl.SetAt(m_pos, GetLocationURL());
}
m_iNoPosition = 0;
}
/*
*******************************************************************************/
// FUNCTION : void CIE6mdiView::OnActivateView(BOOL,CView*,CView*)
//
// PURPOSE : triggered when the view is activated/deactivated. If the view is activated,
// we have to refresh the AVI and the address bar with the correct values
//
// PARAMETERS :
// bActivate -
// pActivateView -
// pDeactiveView -
//
// RETURN VALUE : void
//
//
// COMMENTS :
//
//
/*******************************************************************************
*/
void CIE6mdiView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
// update the toolbar
theViewManager.OnActivateView(TRUE,this);
CMDIChildWnd* m_pChild=((CMDIChildWnd*)GetParentFrame());
if (bActivate) {
m_iActivated = 1;
this->UpdateWindow();
// test if we have to stop/start the AVI
if (LookingURL == 1)
((CMainFrame*)(m_pChild->GetMDIFrame()))->StartAnimation();
else
((CMainFrame*)(m_pChild->GetMDIFrame()))->StopAnimation();
// we update the URL bar only if we are active !
((CMainFrame*)(m_pChild->GetMDIFrame()))->SetAddress(GetLocationURL());
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
if (m_iPopupWindow == 1) {
pFrame->m_wndToolBar.SetButtonInfo(8, ID_POPUP_WINDOW_OFF, TBSTYLE_BUTTON, 14);
AfxGetApp()->WriteProfileInt("Settings","NoPopupWindow",1);
}
else {
pFrame->m_wndToolBar.SetButtonInfo(8, ID_POPUP_WINDOW, TBSTYLE_BUTTON, 13);
AfxGetApp()->WriteProfileInt("Settings","NoPopupWindow",0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -