280 lines
9.1 KiB
C++
280 lines
9.1 KiB
C++
// dlgselectinstances.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
//#include "X:\CPA\tempgrp\oac\Inc\EdActors\edactors.h"
|
|
#include "..\inc\edactors\EdAcIRes.h"
|
|
#include "..\inc\edactors\dlgselectinstances.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDlgSelectInstances dialog
|
|
|
|
IMPLEMENT_DYNAMIC (CSimpleCheckListBox, CCheckListBox)
|
|
|
|
CSimpleCheckListBox::CSimpleCheckListBox () : CCheckListBox ()
|
|
{
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : DrawItem
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CSimpleCheckListBox::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
|
|
{
|
|
if (0 > lpDrawItemStruct->itemID)
|
|
return;
|
|
|
|
CDC *pDC = CDC::FromHandle (lpDrawItemStruct->hDC);
|
|
char szText [TEXT_LENGTH];
|
|
SendMessage (LB_GETTEXT, lpDrawItemStruct->itemID, (LPARAM)(LPCSTR)szText);
|
|
CString csText = szText;
|
|
COLORREF rgbTextOld = 0, rgbTextStandard = RGB (0, 0, 255), rgbTextRegular = RGB (82, 16, 0);
|
|
|
|
switch (lpDrawItemStruct->itemData)
|
|
{
|
|
case STANDARD_INSTANCE:
|
|
rgbTextOld = pDC->SetTextColor (rgbTextStandard);
|
|
break;
|
|
case REGULAR_INSTANCE:
|
|
rgbTextOld = pDC->SetTextColor (rgbTextRegular);
|
|
break;
|
|
default:
|
|
ASSERT (FALSE);
|
|
}
|
|
|
|
pDC->DrawText (csText, &lpDrawItemStruct->rcItem, DT_LEFT);
|
|
pDC->SetTextColor (rgbTextOld);
|
|
}
|
|
|
|
|
|
CDlgSelectInstances::CDlgSelectInstances(CStringList &rlstAllInstances, CStringList &rlstStandardInstances, CWnd* pParent /*=NULL*/)
|
|
: CDialog(CDlgSelectInstances::IDD, pParent), m_rlstAllInstances (rlstAllInstances), m_rlstStandardInstances (rlstStandardInstances)
|
|
{
|
|
//{{AFX_DATA_INIT(CDlgSelectInstances)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
m_bAllInstances = FALSE;
|
|
}
|
|
|
|
|
|
void CDlgSelectInstances::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDlgSelectInstances)
|
|
DDX_Control(pDX, IDC_LIST_INSTANCES, m_lstInstances);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDlgSelectInstances, CDialog)
|
|
//{{AFX_MSG_MAP(CDlgSelectInstances)
|
|
ON_BN_CLICKED(IDC_CHECK_ALL, OnCheckAll)
|
|
ON_BN_CLICKED(IDC_CHECK_STANDARD, OnCheckStandard)
|
|
ON_LBN_SELCHANGE(IDC_LIST_INSTANCES, OnSelchangeListInstances)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDlgSelectInstances message handlers
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : OnCheckAll
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSelectInstances::OnCheckAll()
|
|
{
|
|
BOOL bCheckStandardChecked = 1 == ((CButton *)GetDlgItem (IDC_CHECK_STANDARD))->GetCheck ();
|
|
CButton *pCheck = (CButton *)GetDlgItem (IDC_CHECK_ALL);
|
|
int nCheckAll = pCheck->GetCheck ();
|
|
int nCnt = m_lstInstances.GetCount ();
|
|
for (int i = 0; i < nCnt; i++)
|
|
{
|
|
if (0 == nCheckAll && bCheckStandardChecked)
|
|
{
|
|
if (STANDARD_INSTANCE == m_lstInstances.GetItemData (i))
|
|
m_lstInstances.SetCheck (i, 1);
|
|
else
|
|
m_lstInstances.SetCheck (i, 0);
|
|
}
|
|
else
|
|
m_lstInstances.SetCheck (i, nCheckAll);
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : OnCheckStandard
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSelectInstances::OnCheckStandard()
|
|
{
|
|
BOOL bCheckAllChecked = 1 == ((CButton *)GetDlgItem (IDC_CHECK_ALL))->GetCheck ();
|
|
CButton *pCheck = (CButton *)GetDlgItem (IDC_CHECK_STANDARD);
|
|
int nStandardCheck = pCheck->GetCheck ();
|
|
if (bCheckAllChecked && 0 == nStandardCheck)
|
|
{
|
|
pCheck->SetCheck (1);
|
|
return;
|
|
}
|
|
|
|
|
|
int nCnt = m_lstInstances.GetCount ();
|
|
for (int i = 0; i < nCnt; i++)
|
|
{
|
|
if (STANDARD_INSTANCE == m_lstInstances.GetItemData (i))
|
|
m_lstInstances.SetCheck (i, nStandardCheck);
|
|
else
|
|
m_lstInstances.SetCheck (i, 0);
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : OnOK
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSelectInstances::OnOK()
|
|
{
|
|
BOOL bCheckAllChecked = 1 == ((CButton *)GetDlgItem (IDC_CHECK_ALL))->GetCheck ();
|
|
|
|
if (!bCheckAllChecked)
|
|
{
|
|
m_rlstAllInstances.RemoveAll ();
|
|
int nCnt = m_lstInstances.GetCount ();
|
|
for (int iInx = 0; iInx < nCnt; iInx++)
|
|
{
|
|
BOOL bInstanceSelected = 1 == m_lstInstances.GetCheck (iInx);
|
|
if (bInstanceSelected)
|
|
{
|
|
CString csInstanceName;
|
|
m_lstInstances.GetText (iInx, csInstanceName);
|
|
m_rlstAllInstances.AddTail (csInstanceName);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
m_bAllInstances = TRUE;
|
|
|
|
//if allCheckChecked then all the instances remain in the list
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : OnInitDialog
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
BOOL CDlgSelectInstances::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
POSITION pos = m_rlstAllInstances.GetHeadPosition ();
|
|
while (pos)
|
|
{
|
|
CString csInstanceName = m_rlstAllInstances.GetNext (pos);
|
|
DWORD dwType = REGULAR_INSTANCE;
|
|
if (mfn_bIsAStandardInstance (csInstanceName))
|
|
dwType = STANDARD_INSTANCE;
|
|
|
|
int iInx = m_lstInstances.AddString (csInstanceName);
|
|
ASSERT (0 <= iInx);
|
|
m_lstInstances.SetItemData (iInx, dwType);
|
|
}
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : OnSelchangeListInstances
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
void CDlgSelectInstances::OnSelchangeListInstances()
|
|
{
|
|
CSimpleCheckListBox *pList = (CSimpleCheckListBox *)GetDlgItem (IDC_LIST_INSTANCES);
|
|
int nSel = pList->GetCurSel ();
|
|
if (LB_ERR == nSel)
|
|
return;
|
|
|
|
if (0 == pList->GetCheck (nSel)) //uncheck
|
|
{
|
|
((CButton *)GetDlgItem (IDC_CHECK_ALL))->SetCheck (0);
|
|
((CButton *)GetDlgItem (IDC_CHECK_STANDARD))->SetCheck (0);
|
|
}
|
|
else
|
|
((CButton *)GetDlgItem (IDC_CHECK_STANDARD))->SetCheck (0);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Method : mfn_bIsAStandardInstance
|
|
// Date : 98/06/25
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Description :
|
|
// Author : Stegaru Cristian - CPA
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Modification :
|
|
// Date :
|
|
// By :
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
BOOL CDlgSelectInstances::mfn_bIsAStandardInstance (CString csInstanceName)
|
|
{
|
|
BOOL bIsStandardInstance = FALSE;
|
|
POSITION pos = m_rlstStandardInstances.GetHeadPosition ();
|
|
while (pos && !bIsStandardInstance)
|
|
{
|
|
const CString csName = m_rlstStandardInstances.GetNext (pos);
|
|
if (csName == csInstanceName)
|
|
bIsStandardInstance = TRUE;
|
|
}
|
|
return bIsStandardInstance;
|
|
}
|
|
|
|
|
|
|