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

📄 showwordview.cpp

📁 随着计算机信息技术的飞速发展
💻 CPP
字号:
// ShowWordView.cpp : implementation of the CShowWordView class
//

#include "stdafx.h"
#include "ShowWord.h"

#include "ShowWordDoc.h"
#include "ShowWordView.h"
#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CShowWordView

IMPLEMENT_DYNCREATE(CShowWordView, CView)

BEGIN_MESSAGE_MAP(CShowWordView, CView)
	//{{AFX_MSG_MAP(CShowWordView)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShowWordView construction/destruction

CShowWordView::CShowWordView()
{
	// TODO: add construction code here

}

CShowWordView::~CShowWordView()
{
}

BOOL CShowWordView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CShowWordView drawing

void CShowWordView::OnDraw(CDC* pDC)
{
	CShowWordDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here

	// 重绘窗口
	if (m_Web.m_hWnd != NULL)
		m_Web.RedrawWindow();
}

/////////////////////////////////////////////////////////////////////////////
// CShowWordView printing

BOOL CShowWordView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CShowWordView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CShowWordView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CShowWordView diagnostics

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

void CShowWordView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CShowWordDoc* CShowWordView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CShowWordDoc)));
	return (CShowWordDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CShowWordView message handlers

void CShowWordView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	// 得到客户区
	CRect rect;
	GetClientRect(&rect);

	// 创建控件窗体
	m_Web.Create(NULL, WS_CHILD | WS_VISIBLE, rect, this, ID_WORD);

	// 得到并保存要打开的文件路径
	m_sFilePath = ((CMainFrame*)AfxGetApp()->GetMainWnd())->m_sPath;
	((CMainFrame*)AfxGetApp()->GetMainWnd())->m_sPath = "about:blank";

	// 打开指定的文件
	m_Web.Navigate(m_sFilePath, NULL, NULL, NULL, NULL);	

	// 窗体设置为大小可变
	m_Web.SetResizable(TRUE);
}

void CShowWordView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);

	if (m_Web.m_hWnd != NULL)
	{
		// 得到新的客户区
		CRect rect;
		GetClientRect(&rect);

		// 设置新的窗口位置
		m_Web.SetWindowPos(&wndTop, rect.left, rect.top, rect.Width(), rect.Height(), NULL);

		// 重绘窗体
		m_Web.RedrawWindow();
	}
}

⌨️ 快捷键说明

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