home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
pserv.cpl
/
pserv-2.4.exe
/
source
/
ChooseColumnsDialog.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2005-01-05
|
4KB
|
127 lines
// ChooseColumnsDialog.cpp : implementation file
//
#include "stdafx.h"
#include "pserv2.h"
#include "ChooseColumnsDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChooseColumnsDialog dialog
CChooseColumnsDialog::CChooseColumnsDialog(CListViewEntries* pEntries, CWnd* pParent /*=NULL*/)
: CDialog(CChooseColumnsDialog::IDD, pParent),
m_pEntries( pEntries )
{
//{{AFX_DATA_INIT(CChooseColumnsDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CChooseColumnsDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChooseColumnsDialog)
DDX_Control(pDX, IDC_LIST2, m_lbTarget);
DDX_Control(pDX, IDC_LIST1, m_lbSource);
//}}AFX_DATA_MAP
if( pDX->m_bSaveAndValidate )
{
CString buffer;
for( int i = 0, nItems = m_lbSource.GetCount(); i < nItems; i++ )
{
m_lbSource.GetText(i, buffer);
CListViewColumn* c = m_pEntries->GetColumnByName(buffer);
if( c )
{
c->m_dwDisplayOrder = -1;
}
}
for( i = 0, nItems = m_lbTarget.GetCount(); i < nItems; i++ )
{
m_lbTarget.GetText(i, buffer);
CListViewColumn* c = m_pEntries->GetColumnByName(buffer);
if( c )
{
c->m_dwDisplayOrder = i;
}
}
m_pEntries->RefreshDisplayColumns();
}
else
{
DWORD dwNumberOfColumns = m_pEntries->m_Columns.GetSize();
for( DWORD dwFindColumnIndex = 0; dwFindColumnIndex < dwNumberOfColumns; dwFindColumnIndex++ )
{
for( DWORD dwIsColumnIndex = 0; dwIsColumnIndex < dwNumberOfColumns; dwIsColumnIndex++ )
{
CListViewColumn* c = (CListViewColumn*) m_pEntries->m_Columns.GetAt(dwIsColumnIndex);
if( c->m_dwDisplayOrder == dwFindColumnIndex )
{
m_lbTarget.AddString(c->m_strCaption);
break;
}
}
}
for( DWORD dwIsColumnIndex = 0; dwIsColumnIndex < dwNumberOfColumns; dwIsColumnIndex++ )
{
CListViewColumn* c = (CListViewColumn*) m_pEntries->m_Columns.GetAt(dwIsColumnIndex);
if( c->m_dwDisplayOrder == DWORD(-1) )
{
m_lbSource.AddString(c->m_strCaption);
}
}
}
}
BEGIN_MESSAGE_MAP(CChooseColumnsDialog, CDialog)
//{{AFX_MSG_MAP(CChooseColumnsDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChooseColumnsDialog message handlers
void MoveItems(CListBox& from, CListBox& to)
{
int nSelCount = from.GetSelCount();
if( nSelCount )
{
ASSERT( nSelCount < 60 );
int iSelectedItemIndex[60];
int n = from.GetSelItems(nSelCount, iSelectedItemIndex);
ASSERT(n==nSelCount);
CString buffer;
for( int i = nSelCount-1; i >= 0; i-- )
{
from.GetText(iSelectedItemIndex[i], buffer);
from.DeleteString(iSelectedItemIndex[i]);
to.AddString(buffer);
}
}
}
void CChooseColumnsDialog::OnButton1()
{
MoveItems(m_lbSource, m_lbTarget);
}
void CChooseColumnsDialog::OnButton2()
{
MoveItems(m_lbTarget, m_lbSource);
}