controlpos.h

来自「该系统要求建立某小区物业管理系统」· C头文件 代码 · 共 77 行

H
77
字号
//------------------------------------------------------------------------------
// ControlPos.h
// 
//	CControlPos 
//	Position controls on a form's resize 
// 
//		Copyright (c) 2000 Paul Wendt
// 
//		VERSION#	DATE			NAME	DESCRIPTION OF CHANGE
//		--------	----------	----	---------------------
//		1.01  	07/11/2000	PRW	Original creation.
// 
#ifndef CONTROLPOS_H_
#define CONTROLPOS_H_

//----------------------------------------------
// these #define's specify HOW the control
// will move. they can be combined with the
// bitwise or operator
//
#define CP_MOVE_H					1
#define CP_MOVE_V					2
#define CP_RESIZE_H					4
#define CP_RESIZE_V					8

class CControlPos
{
private:
	// internal structure used to hold all information about a CWnd* control
	typedef struct tagCONTROLDATA
	{
		HWND  hControl;		// HWND's never change; some MFC functions return tYgorary CWnd *'s
		DWORD dwStyle;		// check the #define's above
	} CONTROLDATA, *LPCONTROLDATA;
	

public:
	CControlPos(CWnd* pParent = NULL);
	virtual ~CControlPos();

public:
	void SetParent(CWnd* pParent);

	BOOL AddControl(CWnd* pControl, const DWORD& dwStyle = CP_MOVE_H);
	BOOL AddControl(const UINT& unID, const DWORD& dwStyle = CP_MOVE_H);
	BOOL RemoveControl(CWnd* pControl);
	BOOL RemoveControl(const UINT& unID);
	void ResetControls(void);
	virtual void MoveControls(void);

	//---------------------------------------------------
	// most of the time, you don't want to move controls
	// if the user reduces window size [controls can
	// overlap and cause "issues"]
	// negative moves won't move controls when the parent
	// window is getting smaller than its original size
	//
	void SetNegativeMoves(const BOOL& fNegativeMoves = TRUE);
	BOOL GetNegativeMoves(void) const;

protected:
	virtual void UpdateParentSize(void);

private:
	CWnd*  m_pParent;		
	int    m_nOldParentWidth;			
	int    m_nOldParentHeight;
	int    m_nOriginalParentWidth;
	int    m_nOriginalParentHeight;
	BOOL   m_fNegativeMoves;

	CObArray m_awndControls;
};


#endif

⌨️ 快捷键说明

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