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

📄 resizableformview.h

📁 当我们使用formview时
💻 H
字号:
#if !defined(AFX_RESIZABLEFORMVIEW_H__5FCBDA95_C53B_11D4_B7AB_0050DAB84384__INCLUDED_)
#define AFX_RESIZABLEFORMVIEW_H__5FCBDA95_C53B_11D4_B7AB_0050DAB84384__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CResizableFormView form view

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif

#ifndef __AFXTEMPL_H
#include <afxtempl.h>
#endif

#if !defined(__SIZE_ANCHORS_)
#define __SIZE_ANCHORS_

const CSize
	NOANCHOR(-1,-1),
	TOP_LEFT(0,0), TOP_CENTER(50,0), TOP_RIGHT(100,0),
	MIDDLE_LEFT(0,50), MIDDLE_CENTER(50,50), MIDDLE_RIGHT(100,50),
	BOTTOM_LEFT(0,100), BOTTOM_CENTER(50,100), BOTTOM_RIGHT(100,100);
#endif // !defined(__SIZE_ANCHORS_)

// jms - 11/28/00 - new code starts
struct FORMCONTROL
{
	UINT  nID;
	CRect rect;
	CSize tlType;
	CSize brType;
	HWND  hWnd;
};
// jms - 11/28/00 - new code stops

class CResizableFormView : public CFormView
{
protected:
	CResizableFormView();           // protected constructor used by dynamic creation
	CResizableFormView(UINT nIDTemplate);
	DECLARE_DYNCREATE(CResizableFormView)

// Attributes
private:
	// flags
	BOOL m_bShowGrip;
	BOOL m_bUseMaxTrack;
	BOOL m_bUseMinTrack;
	BOOL m_bUseMaxRect;
	BOOL m_bEnableSaveRestore;

	// internal status
	CString m_sSection;			// section name and
	CString m_sEntry;			// entry for save/restore

	BOOL m_bInitDone;			// if all internal vars initialized

	SIZE m_szGripSize;			// set at construction time

	CRect m_rcGripRect;			// current pos of grip

	POINT m_ptMinTrackSize;		// min tracking size
	POINT m_ptMaxTrackSize;		// max tracking size
	POINT m_ptMaxPos;			// maximized position
	POINT m_ptMaxSize;			// maximized size

	CPtrList m_plLayoutList;	// list of repositionable controls

	class Layout
	{
	public:
		HWND hwnd;

		BOOL adj_hscroll;
		BOOL need_refresh;

		// upper-left corner
		SIZE tl_type;
		SIZE tl_margin;
		
		// bottom-right corner
		SIZE br_type;
		SIZE br_margin;
	
	public:
		Layout(HWND hw, SIZE tl_t, SIZE tl_m, 
			SIZE br_t, SIZE br_m, BOOL hscroll, BOOL refresh)
		{
			hwnd = hw;

			adj_hscroll = hscroll;
			need_refresh = refresh;

			tl_type = tl_t;
			tl_margin = tl_m;
			
			br_type = br_t;
			br_margin = br_m;
		};
	};


// Form Data
public:
	//{{AFX_DATA(CResizableFormView)
	enum { IDD = 0};
	//}}AFX_DATA

// Attributes
public:

// Operations
public:

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

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

// used internally
private:
	void Construct();
	void ArrangeLayout();

// callable from derived classes
//protected:
public:
	// Generated message map functions
	//{{AFX_MSG(CResizableFormView)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

protected:
	void AddAnchor(HWND wnd,     CSize tl_type, CSize br_type = NOANCHOR);	// add anchors to a control
	void AddAnchor(UINT ctrl_ID, CSize tl_type, CSize br_type = NOANCHOR)	// add anchors to a control
	{
		AddAnchor(::GetDlgItem(*this, ctrl_ID), tl_type, br_type);
	};

// functions added by jms
protected:
	CTypedPtrArray<CPtrArray, FORMCONTROL*> m_tpaControls;
	void AddResizedControl(UINT nID, CSize tl_type, CSize br_type = NOANCHOR);
	void AnchorControls();
	FORMCONTROL* GetFormControl(HWND hWnd);

};

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

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RESIZABLEFORMVIEW_H__5FCBDA95_C53B_11D4_B7AB_0050DAB84384__INCLUDED_)

⌨️ 快捷键说明

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