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

📄 doublelistpicker.h

📁 一个可以管理当前窗口显示和隐藏的完整程序
💻 H
字号:
////////////////////////////////////////////////////////////////////////////
// File:	DoubleListPicker.h
// Version:	2
// Created:	07-Feb-2003
//
// Author:	Paul S. Vickery
// E-mail:	paul@vickeryhome.freeserve.co.uk
//
// CStatic derived control to encapsulate two lists, and buttons, to allow 
// users to pick from one list and add to the other
//
// You are free to use or modify this code, with no restrictions, other than
// you continue to acknowledge me as the original author in this source code,
// or any code derived from it.
//
// If you use this code, or use it as a base for your own code, it would be 
// nice to hear from you simply so I know it's not been a waste of time!
//
// Copyright (c) 2002-2003 Paul S. Vickery
//
////////////////////////////////////////////////////////////////////////////
// Version History:
//
// Version 2 - 07-Feb-2003
// =======================
// Added facility to show the lists horizontally. Uses code based on code by 
// Anneke Sicherer-Roetman (drawing to a bitmap device context) and Stefan 
// Schwedt (drawing rotated text)
//
// Version 1 - 31-Jul-2002
// =======================
// Initial version
// 
////////////////////////////////////////////////////////////////////////////
// PLEASE LEAVE THIS HEADER INTACT
////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_DOUBLELISTPICKER_H__3779B251_9B04_11D6_860C_0000B48746CF__INCLUDED_)
#define AFX_DOUBLELISTPICKER_H__3779B251_9B04_11D6_860C_0000B48746CF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CDoubleListPicker window

#define NUM_CTRLS	9 // number of 'child' controls in picker

class CDoubleListPicker : public CStatic
{
// Construction
public:
	CDoubleListPicker();
	virtual BOOL Create(LPCTSTR lpszTitle, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

// Attributes
public:
	#define ID_BASE_ID		((UINT)-1)
	enum { 
	  ID_TITLE = (ID_BASE_ID - 1),			// Title static control
	  ID_LABEL_LEFT = (ID_BASE_ID - 2),		// Left label
	  ID_LABEL_RIGHT = (ID_BASE_ID - 3),		// Right Label
	  ID_BTN_MOVE_RIGHT = (ID_BASE_ID - 4),		// ">" button
	  ID_BTN_MOVE_LEFT = (ID_BASE_ID - 5),		// "<" button
	  ID_BTN_MOVE_ALL_RIGHT = (ID_BASE_ID - 6), 	// ">>" button
	  ID_BTN_MOVE_ALL_LEFT = (ID_BASE_ID - 7),	// "<<" button
	  ID_LIST_LEFT = (ID_BASE_ID - 8),		// Left list
	  ID_LIST_RIGHT = (ID_BASE_ID - 9),		// Right list
	};

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDoubleListPicker)
	protected:
	virtual void PreSubclassWindow();
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
public:
	int GetListItems(BOOL bLeft, CStringArray& saItems) const;
	int GetListItems(BOOL bLeft, CStringList& slistItems) const;
	int AddListItems(BOOL bLeft, const CStringArray& saItems);
	int AddListItems(BOOL bLeft, const CStringList& slistItems);
	int AddListItem(BOOL bLeft, LPCSTR lpszItem, LPVOID lpData);
	int AddListItem(BOOL bLeft, LPCSTR lpszItem, DWORD dwData = 0);
	void SetListSort(BOOL bLeft, BOOL bSort = TRUE);
	void SetListMultiSel(BOOL bLeft, BOOL bMultiSel = TRUE);
	void SetTitle(LPCSTR lpszTitle = NULL);
	void SetLabels(LPCSTR lpszLabelLeft = NULL, LPCSTR lpszLabelRight = NULL);
	CListBox& GetListCtrl(BOOL bLeft = TRUE) const;
	CStatic& GetLabelCtrl(BOOL bLeft = TRUE) const;
	CStatic& GetTitleCtrl() const;
	CString GetTitle() const { return m_sTitle; }
	CString GetLabel(BOOL bLeft = TRUE) { return bLeft ? m_sLabelLeft : m_sLabelRight; }
	void SetHorizontal(BOOL bHorizontal = TRUE);
	BOOL GetHorizontal() const { return m_bHorizontal; }

	// Generated message map functions
protected:
	BOOL CreateList(BOOL bLeft, CWnd* pParent);
	void RecreateList(BOOL bLeft);
	void MoveListItems(BOOL bRightToLeft = FALSE, BOOL bAll = FALSE);
	CString m_sTitle;
	CString m_sLabelLeft;
	CString m_sLabelRight;
	BOOL m_bSortListLeft;
	BOOL m_bSortListRight;
	BOOL m_bMultiSelLeft;
	BOOL m_bMultiSelRight;
	void DoSizing();
	BOOL CreateChildControls();

	class CButtonDLP : public CButton
	{
	protected:
		CDoubleListPicker* m_pPicker;
		afx_msg BOOL OnClick() { m_pPicker->OnControlNotification(GetDlgCtrlID(), BN_CLICKED); return FALSE; }
		DECLARE_MESSAGE_MAP()
		friend CDoubleListPicker;
	};
	friend CButtonDLP;

	class CListBoxDLP : public CListBox
	{
	protected:
		CDoubleListPicker* m_pPicker;
		afx_msg BOOL OnDblClk() { m_pPicker->OnControlNotification(GetDlgCtrlID(), LBN_DBLCLK); return FALSE; }
		DECLARE_MESSAGE_MAP()
		friend CDoubleListPicker;
	};
	friend CListBoxDLP;

	CStatic m_labelTitle;
	CStatic m_labelLeft;
	CListBoxDLP m_listLeft;
	CButtonDLP m_btnMoveRight;
	CButtonDLP m_btnMoveAllRight;
	CButtonDLP m_btnMoveLeft;
	CButtonDLP m_btnMoveAllLeft;
	CStatic m_labelRight;
	CListBoxDLP m_listRight;

	BOOL m_bHorizontal;
	void SetRotatedButtonText(CButton& btn, LPCTSTR lpszText = NULL, int nAngle = 270);

	CWnd* m_apCtrls[9];

	void OnControlNotification(UINT nID, UINT nCode);

	//{{AFX_MSG(CDoubleListPicker)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnEnable(BOOL bEnable);
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_DOUBLELISTPICKER_H__3779B251_9B04_11D6_860C_0000B48746CF__INCLUDED_)

⌨️ 快捷键说明

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