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

📄 ekutil.h

📁 是MFCfaq的一本书的源代码
💻 H
字号:
// EkUtil.h: header file
//

//=======================================================//
// Chapter 02: Documents and Document Templates          //
//=======================================================//

///////////////////////////////////////////////////////////
// CEkDocList: class declaration
//
// Enumerator class for the document objects
// in an MDI application.

#include <afxtempl.h>	// For CTypedPtrList template

class CEkDocList
{
public:
	// Constuction - Destruction
	CEkDocList();	// The constructor fills our internal
					// list of pointer to document objects

	~CEkDocList();

	// Operations
	CDocument* GetNextDoc();  // Gets next document object

	// Forbid copy and assignment of CEkDocList objects
private:
	CEkDocList( const CEkDocList& );
	const CEkDocList& operator = ( const CEkDocList& );

	// Implementation
private:

	// Internal list of pointers to document objects
	CTypedPtrList< CObList, CDocument* > m_DocList;

	// Current position in the above list
	POSITION m_posDocList;
};

///////////////////////////////////////////////////////////
// EkCloseDocument: function declaration
// 
// Close a document object after prompting the user
// to save the document if it was modified.

void EkCloseDocument( CDocument* pDoc );

///////////////////////////////////////////////////////////
// EkGetActiveDocument: function declaration
//
// Get a pointer to the active document object or NULL.

CDocument* EkGetActiveDocument();

//=======================================================//
// Chapter 03: Views and Frame Windows                   //
//=======================================================//

///////////////////////////////////////////////////////////
// CEkFixedFormFrame: class declaration
//
// Frame window for a FormView.
// The frame window is not resizable by the user, but it
// initially sizes itself to fit its associated FormView.

class CEkFixedFormFrame : public CMDIChildWnd
{
	DECLARE_DYNCREATE(CEkFixedFormFrame)
protected:
	CEkFixedFormFrame();           // protected constructor used by dynamic creation

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CEkFixedFormFrame)
	protected:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CEkFixedFormFrame();

	// Generated message map functions
	//{{AFX_MSG(CEkFixedFormFrame)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


///////////////////////////////////////////////////////////
// CEkLockableSplitter window: class declaration
//
// Splitter window that can be "locked".

class CEkLockableSplitter : public CSplitterWnd
{
// Construction
public:
	CEkLockableSplitter();

// Attributes
public:

// Operations
public:
	void SetLock( BOOL bLock );
	BOOL GetLock() const;
	void ToggleLock();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CEkLockableSplitter)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CEkLockableSplitter();

protected:
	BOOL m_bLocked;

	// Generated message map functions
protected:
	//{{AFX_MSG(CEkLockableSplitter)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

///////////////////////////////////////////////////////////
// EkCreateNewWindow: function declaration
// 
// Create a new "window" on a document--that is, a new
// child frame window with a new view inside it.

CFrameWnd* EkCreateNewWindow( CDocTemplate* pTemplate,
                              CDocument* pDocument );

///////////////////////////////////////////////////////////
// EkGetActiveFrame: function declaration
//
// Get a pointer to the active frame window or NULL.

CFrameWnd* EkGetActiveFrame();

///////////////////////////////////////////////////////////
// EkGetActiveView: function declaration
//
// Get a pointer to the active view or NULL.

CView* EkGetActiveView();

///////////////////////////////////////////////////////////
// EkSwitchViewInFrame: function declaration
// 
// Replace the current view in a frame window by another
// view.

void EkSwitchViewInFrame(	CFrameWnd* pFrame,
							CRuntimeClass* pViewClass );

///////////////////////////////////////////////////////////
// EkSwitchViewInSplitter: function declaration

// Replace the current view inside a splitter window pane
// by another view.

void EkSwitchViewInSplitter(	CSplitterWnd* pSplitter,
								int row, int col,
								CRuntimeClass* pViewClass );

//=======================================================//
// Chapter 04: Dialog Boxes                              //
//=======================================================//

///////////////////////////////////////////////////////////
// EkDrawBitmap: function declaration
//
// Draw a bitmap inside a device context.

void EkDrawBitmap( CDC* pDC, CBitmap* pBitmap, CRect rect, BOOL bCenter = TRUE );

///////////////////////////////////////////////////////////
// EkExpandDialog: function declaration
//
// Expand or contract an expanding dialog box.

void EkExpandDialog( CDialog* pDlg, UINT nSmallID, UINT nLargeID, UINT nButtonID );

//=======================================================//
// Chapter 05: Property Sheets                           //
//=======================================================//

///////////////////////////////////////////////////////////
// EkCenterPropertySheetButtons: function declaration
//
// Conditionally center standard property sheet buttons
// (useful when some buttons are hidden).

void EkCenterPropertySheetButtons(	CPropertySheet* pPSheet,
									BOOL bCenterOK,
									BOOL bCenterCancel,
									BOOL bCenterApply );
									
///////////////////////////////////////////////////////////
// EkCreateEmbeddedPropertySheet: function declaration
//
// Create a property sheet that is embedded inside another
// window.

BOOL EkCreateEmbeddedPropertySheet(	CWnd* pParent,
									CPropertySheet* pPSheet,
									DWORD dwStyle = WS_CHILD | WS_VISIBLE,
									DWORD dwExStyle = 0 );

///////////////////////////////////////////////////////////
// EkHidePropertySheetButtons: function declaration
//
// Conditionally hide any (or all) of the standard
// property sheet buttons.

void EkHidePropertySheetButtons(	CPropertySheet* pPSheet,
									BOOL bHideOK,
									BOOL bHideCancel, 
									BOOL bHideApply );

///////////////////////////////////////////////////////////
// EkPositionEmbeddedPropertySheet: function declaration
//
// Position and resize an embedded property sheet.

void EkPositionEmbeddedPropertySheet(	CWnd* pParent,
										CPropertySheet* pPSheet,
										CRect rcNewPosition );
										
void EkPositionEmbeddedPropertySheet(	CWnd* pParent,
										CPropertySheet* pPSheet,
										UINT nIDPSheetArea );

///////////////////////////////////////////////////////////
// EkResizePropertySheet: function declaration
//
// Horizontally resize a property sheet window along with
// the associated tab control.

void EkResizePropertySheet( CPropertySheet* pPSheet, int nWidth );

//=======================================================//
// Chapter 06: Toolbars and Status Bars                  //
//=======================================================//

///////////////////////////////////////////////////////////
// CEkDrawStatusBar: class declaration
//
// Status bar class that triggers the UPDATE_COMMAND_UI
// message when repainting, ensuring that its drawing
// panes paint themselves correctly.

class CEkDrawStatusBar : public CStatusBar
{
// Construction
public:
	CEkDrawStatusBar();

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CEkDrawStatusBar)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CEkDrawStatusBar();

	// Generated message map functions
protected:
	//{{AFX_MSG(CEkDrawStatusBar)
	afx_msg void OnPaint();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

///////////////////////////////////////////////////////////
// EkCreateProgressBar: function declaration
//
// Create a progress indicator inside a status bar.

BOOL EkCreateProgressBar(	CProgressCtrl* pProgressCtrl,
							CStatusBar* pStatusBar,
							LPCTSTR szMessage = NULL,
							int nPaneIndex = 0,
							int cxMargin = 10,
							int cxMaxWidth = -1,
							UINT nIDControl = 1 );

///////////////////////////////////////////////////////////
// EkCreateToolBar: function declaration
//
// Create a toolbar window, load its associated resource,
// and define its styles.

BOOL EkCreateToolBar(	CFrameWnd* pParentFrame,
						CToolBar* pBar,
						UINT nIDBar,
						UINT nIDResource = 0,
						DWORD dwStyle1 = WS_CHILD | WS_VISIBLE | CBRS_TOP,
						DWORD dwStyle2 = CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );

///////////////////////////////////////////////////////////
// EkDockBarNextTo: function declaration
//
// Dock a toolbar next to an already docked toolbar on the
// same docking band.

void EkDockBarNextTo(	CControlBar* pNewBar,
						CControlBar* pDockedBar,
						UINT nDockBarID = AFX_IDW_DOCKBAR_TOP );

///////////////////////////////////////////////////////////
// EkDockToolBar: function declaration
//
// Define a toolbar's docking behavior and dock the toolbar
// at the specified position.

void EkDockToolBar(	CFrameWnd* pParentFrame,
					CToolBar* pBar,
					UINT nDockBarID = AFX_IDW_DOCKBAR_TOP,
					CControlBar* pBarNextTo = NULL,
					DWORD dwStyleDocking = CBRS_ALIGN_ANY );

///////////////////////////////////////////////////////////
// EkIsBarVisible: function declaration
//
// Find out if a control bar is currently visible.

BOOL EkIsBarVisible( CControlBar* pBar );

///////////////////////////////////////////////////////////
// EkSetToolBarButtonText: function declaration
//
// Set the text labels of the buttons on a toolbar.

void EkSetToolBarButtonText( CToolBar* pBar, UINT nIDStrings, TCHAR chSep = _T( '\n' ) );

///////////////////////////////////////////////////////////
// EkSwitchBars: function declaration
//
// Hide or show the correct toolbar in a pair, while
// preserving the toolbar's child window ID.

void EkSwitchBars(	CFrameWnd* pFrame,
					CControlBar* pBar1,
					CControlBar* pBar2,
					BOOL bShowBar2,
					BOOL bDelay = TRUE );

//=======================================================//
// Chapter 07: Menus                                     //
//=======================================================//

///////////////////////////////////////////////////////////
// EkUpdateMenuUI: function declaration
//
// Implement the UPDATE_COMMAND_UI mechanism for dynamic
// popup menus.

void EkUpdateMenuUI( CWnd* pOwner, CMenu* pMenu, BOOL bAutoMenuEnable = TRUE );

//=======================================================//
// Chapter 08: Printing and print preview                //
//=======================================================//

///////////////////////////////////////////////////////////
// CEkPrintingDlg: class declaration
//
// Custom Printing... dialog box.

#include "EkResource.h"

class CEkPrintingDlg : public CDialog
{
// Construction
public:
	CEkPrintingDlg(CWnd* pParent, CWnd* pStandardDialog);

// Dialog Data
	//{{AFX_DATA(CEkPrintingDlg)
	enum { IDD = IDD_EK_PRINTING_DLG };
	CStatic	m_DocName;
	CStatic	m_PrinterName;
	CStatic	m_PortName;
	CStatic	m_PageNum;
	CProgressCtrl	m_Progress;
	//}}AFX_DATA

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CEkPrintingDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	CWnd* m_pStandardDialog;	// Pointer to MFC's "Printing..." dialog

	// Generated message map functions
	//{{AFX_MSG(CEkPrintingDlg)
	virtual BOOL OnInitDialog();
	virtual void OnCancel();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

///////////////////////////////////////////////////////////
// EkChangePrintingOrientation: function declaration
//
// Dynamically change the printing orientation during a
// print job.

void EkChangePrintingOrientation( CDC* pDC, CPrintInfo* pInfo, short NewOrientation );

///////////////////////////////////////////////////////////
// EkColorRefToGray: function declaration
//
// Convert a color to the corresponding gray shade.

COLORREF EkColorRefToGray( COLORREF crColor );

///////////////////////////////////////////////////////////
// EkCreateDefaultPrinterDC: function declaration
//
// Create a device context associated with the currently
// selected printer.

BOOL EkCreateDefaultPrinterDC( CDC* pDC );

///////////////////////////////////////////////////////////
// EkGetPrintMode: function declaration
//
// Find out the current print mode given a pointer to
// either a CPrintInfo or a device context object.

enum EK_PRINT_MODE { DISPLAYING, PRINTING, PREVIEWING };

EK_PRINT_MODE EkGetPrintMode( CPrintInfo* pInfo );

EK_PRINT_MODE EkGetPrintMode( CDC* pDC );

///////////////////////////////////////////////////////////
// EkIsMonoPreview: function declaration
//
// Find out if a device context is currently used in print
// preview mode for a monochrome printer.

BOOL EkIsMonoPreview( CDC* pDC );

⌨️ 快捷键说明

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