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

📄 listboxbasicdlg.cpp

📁 这些源代码
💻 CPP
字号:
// ListBoxBasicDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Controls.h"
#include "ListBoxBasicDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CListBoxBasicDlg

IMPLEMENT_DYNAMIC(CListBoxBasicDlg, CDialog)

CListBoxBasicDlg::CListBoxBasicDlg(CWnd* pParent)
	:CDialog (IDD, pParent)
{
	//{{AFX_DATA_INIT(CListBoxBasicDlg)
	//}}AFX_DATA_INIT
}

CListBoxBasicDlg::~CListBoxBasicDlg()
{
}


void CListBoxBasicDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListBoxBasicDlg)
	DDX_Control(pDX, IDC_REMOVEBUTTON, m_RemoveButton);
	DDX_Control(pDX, IDC_ADDBUTTON, m_AddButton);
	DDX_Control(pDX, IDC_BASICLIST, m_BasicList);
	DDX_Control(pDX, IDC_ACTIONLIST, m_ActionList);
	DDX_Control(pDX, IDC_POOLLIST, m_PoolList);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CListBoxBasicDlg, CDialog)
	//{{AFX_MSG_MAP(CListBoxBasicDlg)
	ON_LBN_SELCHANGE(IDC_ACTIONLIST, OnSelchangeActionlist)
	ON_LBN_SELCHANGE(IDC_POOLLIST, OnSelchangePoollist)
	ON_LBN_DBLCLK(IDC_POOLLIST, OnDblclkPoollist)
	ON_LBN_DBLCLK(IDC_ACTIONLIST, OnDblclkActionlist)
	ON_LBN_SELCANCEL(IDC_ACTIONLIST, OnSelcancelActionlist)
	ON_LBN_SELCANCEL(IDC_BASICLIST, OnSelcancelBasiclist)
	ON_LBN_SELCANCEL(IDC_POOLLIST, OnSelcancelPoollist)
	ON_LBN_SELCHANGE(IDC_BASICLIST, OnSelchangeBasiclist)
	ON_LBN_DBLCLK(IDC_BASICLIST, OnDblclkBasiclist)
	ON_BN_CLICKED(IDC_ADDBUTTON, OnAddbutton)
	ON_BN_CLICKED(IDC_REMOVEBUTTON, OnRemovebutton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListBoxBasicDlg message handlers

BOOL CListBoxBasicDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();


	WIN32_FIND_DATA fd;
	HANDLE hFind;
	if ((hFind = FindFirstFile (_T("*.*"), &fd)) != NULL)
	{
		do
		{
			if (fd.cFileName[0] == '.')
				continue;
//			m_BasicList.AddString (fd.cFileName);
			m_PoolList.AddString (fd.cFileName);
		} while (FindNextFile (hFind, &fd));
	}

	m_BasicList.Dir (0x4000 | 0x8000, "");
	m_BasicList.Dir (0x0010 | 0x8000, "M:\\cfiles\\bc5\\hax\\*.*");
	m_BasicList.Dir (0x0007, "M:\\cfiles\\bc5\\hax\\*.*");

	CString strText;
	m_BasicList.GetText (1, strText);
	m_BasicList.SetSel (1);
	m_PoolList.SetCurSel (0);
	char str[_MAX_PATH];
	DlgDirSelectEx (this->m_hWnd, str, _MAX_PATH, IDC_BASICLIST);

	m_AddButton.EnableWindow (FALSE);
	m_RemoveButton.EnableWindow (FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

/////////////////////////////////////////////////////////////////////////////
// Functions for m_BasicList

void CListBoxBasicDlg::OnSelcancelBasiclist() 
{
	// TODO: Add your control notification handler code here
	
}

void CListBoxBasicDlg::OnSelchangeBasiclist() 
{
	// TODO: Add your control notification handler code here
	
}

void CListBoxBasicDlg::OnDblclkBasiclist() 
{
	// TODO: Add your control notification handler code here
	
}

/////////////////////////////////////////////////////////////////////////////
// Functions for m_PoolList

void CListBoxBasicDlg::OnSelchangePoollist()
{
	if (m_PoolList.GetSelCount ())
		m_AddButton.EnableWindow (TRUE);
	else
		m_AddButton.EnableWindow (FALSE);
}

void CListBoxBasicDlg::OnDblclkPoollist() 
{
	OnAddbutton ();
}

void CListBoxBasicDlg::OnSelcancelPoollist() 
{
	OnSelchangePoollist();
}

/////////////////////////////////////////////////////////////////////////////
// Functions for m_ActionList

void CListBoxBasicDlg::OnSelchangeActionlist() 
{
	if (m_ActionList.GetSelCount ())
		m_RemoveButton.EnableWindow (TRUE);
	else
		m_RemoveButton.EnableWindow (FALSE);
}

void CListBoxBasicDlg::OnDblclkActionlist() 
{
	OnRemovebutton();
}

void CListBoxBasicDlg::OnSelcancelActionlist() 
{
	OnSelchangeActionlist();
}

/////////////////////////////////////////////////////////////////////////////
// Button functions

void CListBoxBasicDlg::OnAddbutton() 
{

	int Count = m_PoolList.GetSelCount ();
	if (!Count)
		return;
	int *SelItems = new int [Count];
	m_PoolList.GetSelItems (Count, SelItems);
	for (int i = 0; i < Count; ++i)
	{
	CString strText;
	int	iIndex;

		m_PoolList.GetText (SelItems[i], strText);
//
//	The item data is a user specified number. It usually is
//	a pointer to a structure containing detailed inofrmation
//
		DWORD dwData = m_PoolList.GetItemData (SelItems[i]);
		iIndex = m_ActionList.AddString ((LPCSTR) strText);
		m_ActionList.SetItemData (iIndex, dwData);
	}
//
//	Delete the selected items from the highest
//	index to the lowest. Deleting the lowest
//	index first changes the relative index of the
//	higher index selected items.
//
	for (i = Count - 1; i >= 0; --i)
	{
		m_PoolList.DeleteString (SelItems[i]);
	}
	delete [] SelItems;
	m_PoolList.SetSel (-1, false);
	if (m_PoolList.GetSelCount ())
		m_AddButton.EnableWindow (true);
	else
		m_AddButton.EnableWindow (false);
	if (m_ActionList.GetSelCount ())
	{
		m_RemoveButton.EnableWindow (true);
	}
	else
	{
		m_RemoveButton.EnableWindow (false);
	}
}

void CListBoxBasicDlg::OnRemovebutton() 
{

	int Count = m_ActionList.GetSelCount ();
	if (!Count)
		return;
	int *SelItems = new int [Count];
	m_ActionList.GetSelItems (Count, SelItems);
	for (int i = 0; i < Count; ++i)
	{
	CString strText;
	int	iIndex;

		m_ActionList.GetText (SelItems[i], strText);
		DWORD dwData = m_ActionList.GetItemData (SelItems[i]);
		iIndex = m_PoolList.AddString ((LPCSTR) strText);
		m_PoolList.SetItemData (iIndex, dwData);
	}
//
//	Delete the selected items from the highest
//	index to the lowest. Deleting the lowest
//	index first changes the relative index of the
//	higher index selected items.
//
	for (i = Count - 1; i >= 0; --i)
		m_ActionList.DeleteString (SelItems[i]);

	delete [] SelItems;
	m_ActionList.SetSel (-1, false);
	if (m_PoolList.GetSelCount ())
		m_AddButton.EnableWindow (true);
	else
		m_AddButton.EnableWindow (false);
	if (m_ActionList.GetSelCount ())
	{
		m_RemoveButton.EnableWindow (true);
	}
	else
	{
		m_RemoveButton.EnableWindow (false);
	}
}

⌨️ 快捷键说明

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