// SetupShowonExpand.cpp : implementation file
//

#include "stdafx.h"
#include "psm.h"
#include "psmdoc.h"
#include "SetupShowonExpand.h"
#include <apl_api.h>

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

/////////////////////////////////////////////////////////////////////////////
// CSetupShowonExpandDlg dialog


CSetupShowonExpandDlg::CSetupShowonExpandDlg(CWnd* pParent /*=NULL*/)
	: CaplTranslateDialog(CSetupShowonExpandDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetupShowonExpandDlg)
	//}}AFX_DATA_INIT
	m_old_state = -1;

	m_auto_expand_items = NULL;
}


void CSetupShowonExpandDlg::DoDataExchange(CDataExchange* pDX)
{
	CaplTranslateDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetupShowonExpandDlg)
	DDX_Control(pDX, IDC_CHECK9, m_check9);
	DDX_Control(pDX, IDC_CHECK8, m_check8);
	DDX_Control(pDX, IDC_CHECK7, m_check7);
	DDX_Control(pDX, IDC_CHECK6, m_check6);
	DDX_Control(pDX, IDC_CHECK5, m_check5);
	DDX_Control(pDX, IDC_CHECK4, m_check4);
	DDX_Control(pDX, IDC_CHECK3, m_check3);
	DDX_Control(pDX, IDC_CHECK2, m_check2);
	DDX_Control(pDX, IDC_CHECK10, m_check10);
	DDX_Control(pDX, IDC_CHECK1, m_check1);
	DDX_Control(pDX, IDOK, m_ok_btn);
	DDX_Control(pDX, IDCANCEL, m_cancel_btn);
	DDX_Control(pDX, IDC_LIST, m_list);
	//}}AFX_DATA_MAP
	DDX_Control(pDX, IDC_CHECK11, m_check11);
	DDX_Control(pDX, IDC_CHECK12, m_check12);
}


BEGIN_MESSAGE_MAP(CSetupShowonExpandDlg, CaplTranslateDialog)
	//{{AFX_MSG_MAP(CSetupShowonExpandDlg)
	ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetupShowonExpandDlg message handlers

BOOL CSetupShowonExpandDlg::OnInitDialog() 
{
	CaplTranslateDialog::OnInitDialog();

	if(m_auto_expand_items==NULL)
	{
		EndDialog(0);
		return FALSE;
	}
	
	m_ok_btn.SetIcon(GetAplStdIco16(APLSTDICO_OK));
	m_ok_btn.SetFlat(FALSE);
	m_cancel_btn.SetIcon(GetAplStdIco16(APLSTDICO_CANCEL));
	m_cancel_btn.SetFlat(FALSE);
	int i = 0;
	i = m_list.AddString( APL_T("Изделие"));
	m_list.SetItemData(i,0);
	i = m_list.AddString( APL_T("Версия изделия"));
	m_list.SetItemData(i,1);
	i = m_list.AddString( APL_T("Экземпляр изделия"));
	m_list.SetItemData(i,2);
	i = m_list.AddString( APL_T("Документ"));
	m_list.SetItemData(i,3);
	i = m_list.AddString( APL_T("Характеристика"));
	m_list.SetItemData(i,4);
	i = m_list.AddString( APL_T("Изменение"));
	m_list.SetItemData(i,5);
	i = m_list.AddString( APL_T("Бизнес процесс"));
	m_list.SetItemData(i,6);
	i = m_list.AddString( APL_T("Ресурс бизнес процесса"));
	m_list.SetItemData(i,7);
	i = m_list.AddString( APL_T("Экземпляр бизнес процесса"));
	m_list.SetItemData(i,8);
//	i = m_list.AddString( APL_T("Категория"));
//	m_list.SetItemData(i,9);
	i = m_list.AddString( APL_T("Партия изделия"));
	m_list.SetItemData(i,10);
	i = m_list.AddString( APL_T("Проект"));
	m_list.SetItemData(i,11);
	i = m_list.AddString( APL_T("Подразделение"));
	m_list.SetItemData(i,12);
	i = m_list.AddString( APL_T("Абонент"));
	m_list.SetItemData(i,13);
	i = m_list.AddString( APL_T("Сотрудник"));
	m_list.SetItemData(i,14);
	i = m_list.AddString(APL_T("Требование"));
	m_list.SetItemData(i,15);
	i = m_list.AddString(APL_T("Справочник"));
	m_list.SetItemData(i,16);
	i = m_list.AddString(APL_T("Элемент структуры справочника"));
	m_list.SetItemData(i,17);

	m_list.SetCurSel(0);
	ShowCheckBoxes();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetupShowonExpandDlg::ShowCheckBoxes()
{
	int i = m_list.GetCurSel();

	if(m_old_state==0)//Изделие
	{
		m_auto_expand_items->m_showintree_prd = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_prd|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_prd|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_prd|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_prd|=APL_SHOW_BP;
		if(m_check5.GetCheck()) m_auto_expand_items->m_showintree_prd|=APL_SHOW_BPINST;
	}
	if(m_old_state==1)//Версия Изделие
	{
		m_auto_expand_items->m_showintree_pdf = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_MATERIAL;
		if(m_check5.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_LOT;
		if(m_check6.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_BP;
		if(m_check7.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_BPINST;
		if(m_check8.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_SUBSTITUTE;
		if(m_check9.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_PRD_INST;
		if(m_check10.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_REQ;
		if(m_check11.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_CHANGE;
		if(m_check12.GetCheck()) m_auto_expand_items->m_showintree_pdf|=APL_SHOW_REFUSAL;
	}
	else if(m_old_state==2)//Экземпляр изделия
	{
		m_auto_expand_items->m_showintree_prdinst = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_prdinst|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_prdinst|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_prdinst|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_prdinst|=APL_SHOW_BP;
		if(m_check5.GetCheck()) m_auto_expand_items->m_showintree_prdinst|=APL_SHOW_BPINST;
		if(m_check6.GetCheck()) m_auto_expand_items->m_showintree_prdinst|=APL_SHOW_REFUSAL;
	}
	else if(m_old_state==3)//Документ
	{
		m_auto_expand_items->m_showintree_doc = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_doc|=APL_SHOW_CHARACT;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_doc|=APL_SHOW_APPROVAL;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_doc|=APL_SHOW_BP;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_doc|=APL_SHOW_VER;
	}
	else if(m_old_state==4)//Характеристика
	{
		m_auto_expand_items->m_showintree_charact = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_charact|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_charact|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_charact|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_charact|=APL_SHOW_VER;
	}
	else if(m_old_state==5)//Изменения
	{
		m_auto_expand_items->m_showintree_change = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_change|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_change|=APL_SHOW_APPROVAL;
	}
	else if(m_old_state==6)//BP
	{
		m_auto_expand_items->m_showintree_bp = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_bp|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_bp|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_bp|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_bp|=APL_SHOW_RES;
		if(m_check5.GetCheck()) m_auto_expand_items->m_showintree_bp|=APL_SHOW_VER;
		if(m_check6.GetCheck()) m_auto_expand_items->m_showintree_bp|=APL_SHOW_BPINST;
	}
	else if(m_old_state==7)//BPRes
	{
		m_auto_expand_items->m_showintree_bpres = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_bpres|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_bpres|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_bpres|=APL_SHOW_APPROVAL;
	}
	else if(m_old_state==8)//BPInst
	{
		m_auto_expand_items->m_showintree_bpinst = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_bpinst|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_bpinst|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_bpinst|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_bpinst|=APL_SHOW_RES;
	}
	else if(m_old_state==9)//Categ
	{
		m_auto_expand_items->m_showintree_categ = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_categ|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_categ|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_categ|=APL_SHOW_VER;
	}
	else if(m_old_state==10)//Lot
	{
		m_auto_expand_items->m_showintree_lot = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_lot|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_lot|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_lot|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_lot|=APL_SHOW_INST;
		if(m_check5.GetCheck()) m_auto_expand_items->m_showintree_lot|=APL_SHOW_BPINST;
	}
	else if(m_old_state==11)//Project
	{
		m_auto_expand_items->m_showintree_project = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_project|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_project|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_project|=APL_SHOW_APPROVAL;
		if(m_check4.GetCheck()) m_auto_expand_items->m_showintree_project|=APL_SHOW_PROJ_ASSOC;		
	}
	else if(m_old_state>=12 && m_old_state<=14)//Орг структура
	{
		m_auto_expand_items->m_showintree_org = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_org|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_org|=APL_SHOW_CHARACT;
	}
	else if(m_old_state==15)//Требование
	{
		m_auto_expand_items->m_showintree_requirement = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_requirement|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_requirement|=APL_SHOW_CHARACT;
		if(m_check3.GetCheck()) m_auto_expand_items->m_showintree_requirement|=APL_SHOW_APPROVAL;
		
	}
	else if(m_old_state==16)//Справочник
	{
		m_auto_expand_items->m_showintree_classifier_system = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_classifier_system|=APL_SHOW_DOC;
		if(m_check2.GetCheck()) m_auto_expand_items->m_showintree_classifier_system|=APL_SHOW_CHARACT;
		
	}
	else if(m_old_state==17)//Элемент структуры справочника
	{
		m_auto_expand_items->m_showintree_classifier_level = 0;
		if(m_check1.GetCheck()) m_auto_expand_items->m_showintree_classifier_level|=APL_SHOW_CHARACT;
	}

	if(i<0) return;
	if(i==m_old_state) return;

	if(m_old_state == (int)m_list.GetItemData(i)) return;

	m_check1.ShowWindow(SW_HIDE);
	m_check2.ShowWindow(SW_HIDE);
	m_check3.ShowWindow(SW_HIDE);
	m_check4.ShowWindow(SW_HIDE);
	m_check5.ShowWindow(SW_HIDE);
	m_check6.ShowWindow(SW_HIDE);
	m_check7.ShowWindow(SW_HIDE);
	m_check8.ShowWindow(SW_HIDE);
	m_check9.ShowWindow(SW_HIDE);
	m_check10.ShowWindow(SW_HIDE);
	m_check11.ShowWindow(SW_HIDE);
	m_check12.ShowWindow(SW_HIDE);

	m_old_state = m_list.GetItemData(i);
	DWORD state = 0;
	if(m_old_state==0)//Изделие
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_prd&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_prd&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_prd&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_prd&APL_SHOW_BP);
		m_check4.SetWindowText( APL_T("Бизнес процессы"));
		m_check5.SetCheck(m_auto_expand_items->m_showintree_prd&APL_SHOW_BPINST);
		m_check5.SetWindowText( APL_T("Экземпляры бизнес процессов"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
		m_check5.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==1)//версии изд.
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_MATERIAL);
		m_check4.SetWindowText( APL_T("Материалы и нормы расхода"));
		m_check5.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_LOT);
		m_check5.SetWindowText( APL_T("Партии изделия"));
		m_check6.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_BP);
		m_check6.SetWindowText( APL_T("Бизнес процессы"));
		m_check7.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_BPINST);
		m_check7.SetWindowText( APL_T("Экземпляры бизнес процессов"));
		m_check8.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_SUBSTITUTE);
		m_check8.SetWindowText( APL_T("Заменители в контексте сборки"));
		m_check9.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_PRD_INST);
		m_check9.SetWindowText( APL_T("Экземпляры изделия"));
		m_check10.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_REQ);
		m_check10.SetWindowText( APL_T("Требования"));
		m_check11.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_CHANGE);
		m_check11.SetWindowText( APL_T("Пакеты изменений"));
		m_check12.SetCheck(m_auto_expand_items->m_showintree_pdf&APL_SHOW_REFUSAL);
		m_check12.SetWindowText( APL_T("Неисправности"));
		
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
		m_check5.ShowWindow(SW_SHOW);
		m_check6.ShowWindow(SW_SHOW);
		m_check7.ShowWindow(SW_SHOW);
		m_check8.ShowWindow(SW_SHOW);
		m_check9.ShowWindow(SW_SHOW);
		m_check10.ShowWindow(SW_SHOW);
		m_check11.ShowWindow(SW_SHOW);
		m_check12.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==2)//Экземпляры изделия
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_prdinst&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_prdinst&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_prdinst&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_prdinst&APL_SHOW_BP);
		m_check4.SetWindowText( APL_T("Бизнес процессы"));
		m_check5.SetCheck(m_auto_expand_items->m_showintree_prdinst&APL_SHOW_BPINST);
		m_check5.SetWindowText( APL_T("Экземпляры бизнес процессов"));
		m_check6.SetCheck(m_auto_expand_items->m_showintree_prdinst&APL_SHOW_REFUSAL);
		m_check6.SetWindowText( APL_T("Неисправности"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
		m_check5.ShowWindow(SW_SHOW);
		m_check6.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==3)//Документ
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_doc&APL_SHOW_CHARACT);
		m_check1.SetWindowText( APL_T("Характеристики"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_doc&APL_SHOW_APPROVAL);
		m_check2.SetWindowText( APL_T("Электронные подписи"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_doc&APL_SHOW_BP);
		m_check3.SetWindowText( APL_T("Бизнес процессы"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_doc&APL_SHOW_VER);
		m_check4.SetWindowText( APL_T("Версии"));
		
		m_check4.SetCheck(m_auto_expand_items->m_showintree_doc&APL_SHOW_VER);
		m_check4.SetWindowText( APL_T("Версии"));
	
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==4)//Характеристика
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_charact&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_charact&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_charact&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_charact&APL_SHOW_VER);
		m_check4.SetWindowText( APL_T("Версии"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==5)//Изменения
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_change&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_change&APL_SHOW_APPROVAL);
		m_check2.SetWindowText( APL_T("Электронные подписи"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==6)//BP
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_bp&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_bp&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_bp&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_bp&APL_SHOW_RES);
		m_check4.SetWindowText( APL_T("Ресурсы"));
		m_check5.SetCheck(m_auto_expand_items->m_showintree_bp&APL_SHOW_VER);
		m_check5.SetWindowText( APL_T("Версии"));
		m_check6.SetCheck(m_auto_expand_items->m_showintree_bp&APL_SHOW_BPINST);
		m_check6.SetWindowText( APL_T("Экземпляры бизнес процессов"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
		m_check5.ShowWindow(SW_SHOW);
		m_check6.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==7)//BPRes
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_bpres&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_bpres&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_bpres&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==8)//BPInst
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_bpinst&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_bpinst&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_bpinst&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_bpinst&APL_SHOW_RES);
		m_check4.SetWindowText( APL_T("Ресурсы"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==9)//Categ
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_categ&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_categ&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_categ&APL_SHOW_VER);
		m_check3.SetWindowText( APL_T("Версии"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==10)//Lot
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_lot&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_lot&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_lot&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_lot&APL_SHOW_INST);
		m_check4.SetWindowText( APL_T("Экземпляры изделия"));
		m_check5.SetCheck(m_auto_expand_items->m_showintree_lot&APL_SHOW_BPINST);
		m_check5.SetWindowText( APL_T("Экземпляры бизнес процессов"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);
		m_check5.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==11)//Project
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_project&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_project&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_project&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));
		m_check4.SetCheck(m_auto_expand_items->m_showintree_project&APL_SHOW_PROJ_ASSOC);
		m_check4.SetWindowText( APL_T("Связанные объекты"));		
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
		m_check4.ShowWindow(SW_SHOW);		
	}
	else if(m_old_state>=12 && m_old_state<=14)//Орг структура
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_org&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_org&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==15)//Требование
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_requirement&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_requirement&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));
		m_check3.SetCheck(m_auto_expand_items->m_showintree_requirement&APL_SHOW_APPROVAL);
		m_check3.SetWindowText( APL_T("Электронные подписи"));

		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
		m_check3.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==16)//Справочник
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_classifier_system&APL_SHOW_DOC);
		m_check1.SetWindowText( APL_T("Документы"));
		m_check2.SetCheck(m_auto_expand_items->m_showintree_classifier_system&APL_SHOW_CHARACT);
		m_check2.SetWindowText( APL_T("Характеристики"));

		m_check1.ShowWindow(SW_SHOW);
		m_check2.ShowWindow(SW_SHOW);
	}
	else if(m_old_state==17)//Элемент структуры справочника
	{
		m_check1.SetCheck(m_auto_expand_items->m_showintree_classifier_level&APL_SHOW_CHARACT);
		m_check1.SetWindowText( APL_T("Характеристики"));

		m_check1.ShowWindow(SW_SHOW);
		m_check1.ShowWindow(SW_SHOW);
	}

}

void CSetupShowonExpandDlg::OnSelchangeList() 
{
	ShowCheckBoxes();
}

void CSetupShowonExpandDlg::OnOK() 
{
	ShowCheckBoxes();

	m_auto_expand_items->SaveData();
	
	CaplTranslateDialog::OnOK();
}
