www.gusucode.com > 几个VC++打印小例子-源码程序 > 几个VC++打印小例子-源码程序/code/Print2/PreviewGotoDlg.cpp

    // PreviewGotoDlg.cpp : implementation file
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "Print2.h"
#include "PreviewGotoDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPreviewGotoDlg dialog


CPreviewGotoDlg::CPreviewGotoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPreviewGotoDlg::IDD, pParent)
{
	m_nMax = 1;
	m_nCurrentPage = 1;
	m_nGotoPage = 1;
	//{{AFX_DATA_INIT(CPreviewGotoDlg)
	m_nGoto = 0;
	//}}AFX_DATA_INIT

}


void CPreviewGotoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPreviewGotoDlg)
	DDX_Control(pDX, IDC_SPIN_GOTO, m_spGoto);
	DDX_Control(pDX, IDC_EDIT_GOTO, m_editGoto);
	DDX_Text(pDX, IDC_EDIT_GOTO, m_nGoto);
	DDV_MinMaxInt(pDX, m_nGoto, 1, 999999);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPreviewGotoDlg, CDialog)
	//{{AFX_MSG_MAP(CPreviewGotoDlg)
	ON_EN_KILLFOCUS(IDC_EDIT_GOTO, OnKillfocusEditGoto)
	ON_BN_CLICKED(IDCANCEL, OnCancel)
	ON_BN_CLICKED(ID_EXECUTE, OnExecute)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPreviewGotoDlg message handlers


void CPreviewGotoDlg::OnKillfocusEditGoto() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_nGoto>m_nMax)
		m_nGoto = m_nMax;
	if(m_nGoto<=0)
		m_nGoto = 1;
	UpdateData(FALSE);	
}

BOOL CPreviewGotoDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_spGoto.SetRange(1, m_nMax);
	m_spGoto.SetPos(m_nCurrentPage);
	m_nGoto = m_nCurrentPage;
	UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



void CPreviewGotoDlg::OnCancel() 
{
	// TODO: Add your control notification handler code here
	m_nGotoPage = m_nCurrentPage;
	CDialog::OnCancel();	
}

void CPreviewGotoDlg::OnExecute() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_nGoto>m_nMax)
		m_nGoto = m_nMax;
	if(m_nGoto<=0)
		m_nGoto = 1;

	m_nGotoPage = m_nGoto;
	CDialog::OnOK();	
}