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

📄 wzdtview.cpp

📁 《vc++扩展编程实例》源码。运用Visual C++ 5.0或6.0的高级编程技巧
💻 CPP
字号:
// WzdTView.cpp : implementation file
//

#include "stdafx.h"
#include "wzd.h"
#include "WzdDoc.h"
#include "WzdTView.h"

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

#define BUTTON_WIDTH 40
#define BUTTON_HEIGTH 25

/////////////////////////////////////////////////////////////////////////////
// CWzdTabbedView

IMPLEMENT_DYNCREATE(CWzdTabbedView, CScrollView)

CWzdTabbedView::CWzdTabbedView()
{
}

CWzdTabbedView::~CWzdTabbedView()
{
}


BEGIN_MESSAGE_MAP(CWzdTabbedView, CScrollView)
	//{{AFX_MSG_MAP(CWzdTabbedView)
	ON_WM_CREATE()
	ON_COMMAND(IDC_WZD_APPLY, OnWzdApply)
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWzdTabbedView drawing

void CWzdTabbedView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	// home the property sheet
	CRect rect;
	m_sheet.GetClientRect(&rect);
	m_sheet.MoveWindow(rect);
	rect.bottom+=BUTTON_HEIGTH+10;

	// move apply button into place
	CRect brect(rect.right-BUTTON_WIDTH-5,
				rect.bottom-BUTTON_HEIGTH-5,
				rect.right-5,
				rect.bottom-5);
	m_button.MoveWindow(brect);

	// size child frame around property sheet
	SIZE size = {rect.Width(), rect.Height()};
	SetScrollSizes(MM_TEXT, size);
	ResizeParentToFit(FALSE);

	// make sure the scroll bars are gone
	SetScrollSizes( MM_TEXT, CSize(20,20));

	// copy document into property pages
	m_pageOne.m_bWzd1=((CWzdDoc*)GetDocument())->m_bWzd1;
	m_pageTwo.m_sEdit=((CWzdDoc*)GetDocument())->m_sEdit;

}

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

/////////////////////////////////////////////////////////////////////////////
// CWzdTabbedView diagnostics

#ifdef _DEBUG
void CWzdTabbedView::AssertValid() const
{
	CScrollView::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// CWzdTabbedView message handlers

int CWzdTabbedView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CScrollView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// create property sheet
	m_sheet.AddPage(&m_pageOne);
	m_sheet.AddPage(&m_pageTwo);
	m_sheet.Create(this,WS_CHILD|WS_VISIBLE);

	// create apply button
	CRect rect (0,0,10,10);
	CFont *pFont=CFont::FromHandle((HFONT)::GetStockObject(ANSI_VAR_FONT));
	m_button.Create("&Apply", WS_VISIBLE | WS_CHILD, rect, this, IDC_WZD_APPLY);  
	m_button.SetFont(pFont);
	
	return 0;
}

void CWzdTabbedView::OnWzdApply() 
{
	m_sheet.PressButton(PSBTN_APPLYNOW);

	((CWzdDoc*)GetDocument())->m_bWzd1=m_pageOne.m_bWzd1;
	((CWzdDoc*)GetDocument())->m_sEdit=m_pageTwo.m_sEdit;
}

BOOL CWzdTabbedView::OnEraseBkgnd(CDC* pDC) 
{
	CPen pen(PS_SOLID,0,GetSysColor(COLOR_BTNFACE));
	CPen *pPen=pDC->SelectObject(&pen);
	CBrush brush(GetSysColor(COLOR_BTNFACE));
	CBrush *pBrush=pDC->SelectObject(&brush);

	CRect rect;
	GetClientRect(&rect);
	pDC->Rectangle(rect);
	pDC->SelectObject(pPen);
	pDC->SelectObject(pBrush);
	return TRUE;
}

⌨️ 快捷键说明

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