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

📄 ie6mdidoc.cpp

📁 VC++实现的多页面浏览器....实现了多种功能
💻 CPP
字号:
// IE6mdiDoc.cpp : implementation of the CIE6mdiDoc class
//

#include "stdafx.h"
#include "IE6mdi.h"

#include "IE6mdiDoc.h"

#include "MainFrm.h"
#include "IE6mdiview.h"

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

/////////////////////////////////////////////////////////////////////////////
// CIE6mdiDoc

IMPLEMENT_DYNCREATE(CIE6mdiDoc, CDocument)

BEGIN_MESSAGE_MAP(CIE6mdiDoc, CDocument)
	//{{AFX_MSG_MAP(CIE6mdiDoc)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CIE6mdiDoc construction/destruction

CIE6mdiDoc::CIE6mdiDoc()
{
}

CIE6mdiDoc::~CIE6mdiDoc()
{
}

BOOL CIE6mdiDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CIE6mdiDoc serialization

void CIE6mdiDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CIE6mdiDoc diagnostics

#ifdef _DEBUG
void CIE6mdiDoc::AssertValid() const
{
	CDocument::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CIE6mdiDoc commands



/*
*******************************************************************************/
// FUNCTION : BOOL  CIE6mdiDoc::OnOpenDocument(LPCTSTR)
//
// PURPOSE	 : open a new document. If we return FALSE, we will be able
//	to open more than one instance of the same document :O) Better
//
// PARAMETERS : 
//		lpszPathName - Path of the document
//
// RETURN VALUE : BOOL 
//
//
// COMMENTS : in return FALSE, no window opened for this document
//
//
/*******************************************************************************
*/
BOOL CIE6mdiDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;;
	CMDIChildWnd *pChild;
	CIE6mdiView *pView;
	CWinApp* pApp = AfxGetApp();
	
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	// test if the extension is .lthm !!!!
	CString s(lpszPathName);
	CString s1;
	s1 = s.Right(5); // ".lthm"
	s1.MakeLower();
	if (s1 == ".lhtm") {
//////////////// LHTM //////////////////////////
		CFile file;
		if (!file.Open(lpszPathName, CFile::modeRead))
		{
			// an error occured
			AfxMessageBox(CString(LPCTSTR(IDS_FILEERROR)));
			return FALSE;
		}
		char *buf = (char*)malloc((file.GetLength()+1)*sizeof(char));
		buf[0]='\0';
		file.Read(buf,file.GetLength());
		file.Close();
		COMBOBOXEXITEM item;
		item.mask = CBEIF_TEXT;
		item.iItem = -1;

		CString s(buf);
		free(buf);
		int p = s.Find("\r\n"); 
		while ( (p != -1)&&(s.IsEmpty() == FALSE)) {
			// s.Left(p): a valid URL
			
			AfxGetApp()->m_pMainWnd->SendMessage(WM_COMMAND,(WPARAM)ID_FILE_NEW,(LPARAM)NULL);
			pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
			pView = (CIE6mdiView *) pChild->GetActiveView();
			pView->Navigate2(s.Left(p));
			
			if (s.Left(p).GetLength() != 0) {
				// add to the combo list 
				item.pszText = (LPTSTR)(LPCTSTR)s.Left(p);
				pFrame->m_wndAddress.InsertItem(&item);
			}

			// prepare the remain of the file
			CString stmp;
			stmp = s.Mid(p+2); // discard \r\n
			s = stmp;
			p = s.Find("\r\n");
		}
		return FALSE; // to prevent an opening of a new window :O)
	}
	else {
/////////////////////// normal document, open the window //////////////////
		AfxGetApp()->m_pMainWnd->SendMessage(WM_COMMAND,(WPARAM)ID_FILE_NEW,(LPARAM)NULL);
		pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
		pView = (CIE6mdiView *) pChild->GetActiveView();
		pView->Navigate2(lpszPathName);
		return FALSE;
	}
}

⌨️ 快捷键说明

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