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

📄 preview.h

📁 这是一个信息管理系统的源代码
💻 H
字号:
#if !defined(AFX_PREVIEW_H__03894546_1C39_11D4_B336_00104B13D514__INCLUDED_)
#define AFX_PREVIEW_H__03894546_1C39_11D4_B336_00104B13D514__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// PreView.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CPreView view
#include "afxpriv.h"
class CMyView;

class CPreView : public CScrollView
{

    DECLARE_DYNCREATE(CPreView)

protected:
	CPreView();           // protected constructor used by dynamic creation

// Attributes
public:
	CMyView* m_pOrigView;
	CMyView* m_pPrintView;
	CPreviewDC * m_pPreviewDC;  // Output and attrib DCs Set, not created
	CDC m_dcPrint;             // Actual printer DC

// Operations

	// Returns TRUE if in a page rect. Returns the page index
	// in nPage and the point converted to 1:1 screen device coordinates

	// Returns .cx/.cy as the numerator/denominator pair for the ratio
	// using CSize for convenience
// Operations

protected:
	virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
	void SetCurrentPage(int nPage);
	void RefreshPreview();
	bool FindPageRect(CPoint& point, int & row,int & column);
	void BeginRowColumn(int rows,int columns);
	void BeginScale(int scale);
	void SetPagePosition();
	int GetPageNumber(int row,int column);
	BOOL SetPrintView(CMyView* pPrintView);
	void SetScale(int scale);
	void ClosePreview();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPreView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	protected:
	virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
	virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
	//}}AFX_VIRTUAL

	CPrintPreviewState* m_pPreviewState; // State to restore
	CDialogBar* m_pToolBar; // Toolbar for preview

							// been displayed on status line
	int m_nCurrentPage;

	CPrintInfo* m_pPreviewInfo;

	
//---------------------------------------------------------------------	
	//我对这个类的修改:
	//当前最大的第一显示页
	int			m_iMaxCurPage;
//数据变量
	int			m_nUserRows;
	int			m_nUserColumns;
	//行数
	int			m_nRows;
	int			m_nMaxRows;
	//列数
	int			m_nColumns;
	int			m_nMaxColumns;
	//页面实际大小
	CSize		m_sizePhysicalPage;
	//页面显示大小
	CSize		m_sizeShowPage;
	//Physical/Show显示比例;10<,,<500	计算时要除以100;
	int			m_iScale;
	//页间距/2
	int			m_iSpaceBetweenl2;

	//区域变量
	//预览窗口显示页的大的区域包括边距,GetClientRect()也行,但考虑到有可能向客户区放控件,会影响客户区的大小;
	CRect		m_rectClient;
	//显示当前屏的所有页的区域
	CRect		m_rectShowPages;
	//每页所占的空间,包括1/2页间距,包括边框,及周围的空间,主要用来确定空间
	CRect		m_rectPage;
	//每页的实际内容的真实反映,提供给OnPrint的区域,这里只记录第一页的区域
	CRect		m_rectDisplayPage1;
	//第一页左上角坐标,利用偏移m_rectDisplayPage1来显示所有页
//	CPoint		m_ptLeftTopPage1;
	//当前被选择的区域
	CRect		m_rectSelected;

//常量
	const int	mc_iPageHW7Between; //显示页的大小 page.high+page.weight/该值 =页间距/2
	const int	mc_iMargin;			//边距,包含在m_rectClient;

//标志,状态
	enum OPERATE{OP_SCALE_ING=0,OP_ROWCOLUMN_ING=1,OP_SELECTED_ING=2};
	//OP_SCALE_ING,OP_ROWCOLUMN_ING
	OPERATE		m_opState;
	struct PAGE_SELECTED
	{
		bool		m_bSelected;
		int			m_nZoomInScale;
		int			m_nPageNumber;

		OPERATE		m_opOldState;
		int			m_iOldRows;
		int			m_iOldColumns;
		int			m_iOldScale;
		int			m_nOldCurrentPage;
	}m_psPageSelected;

	HCURSOR m_hCursorZoomIn;
	HCURSOR m_hCursorZoomOut;
//---------------------------------------------------------------------	


// Implementation
protected:
	void SetMultiPageScroll();
	void SetSinglePageScroll(CDC*pDC);
	void DrawPrint(CDC*pDC);
	void DrawSelectRect(CDC*pDC);
	void DrawFrame(CDC *pDC);
	virtual ~CPreView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(CPreView)
	afx_msg void OnGetRowColumn();
	afx_msg void OnPreviewClose();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnPreviewPrint();
	afx_msg void OnGetScale();
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);	
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()

    friend class CMyView;
	friend BOOL CALLBACK _AfxPreviewCloseProc(CFrameWnd* pFrameWnd);

};
class CMyView : public CScrollView
{
protected:
	CMyView();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(CMyView)

// Attributes
public:

// Operations
public:
	BOOL DoPrintPreview(UINT nIDResource, CMyView* pPrintView,
		                CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMyView)
	protected:
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
	virtual void OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreView* pView);
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CMyView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
public:
	//{{AFX_MSG(CMyView)
	afx_msg void OnFilePrintPreview();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

    friend class CPreView;
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PREVIEW_H__03894546_1C39_11D4_B336_00104B13D514__INCLUDED_)

⌨️ 快捷键说明

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