00001
00002
00003
00004 #include "stdafx.h"
00005 #include "tile_edit_exe.h"
00006 #include "DialogEditList.h"
00007 #include <vector>
00008
00009 #ifdef _DEBUG
00010 #define new DEBUG_NEW
00011 #undef THIS_FILE
00012 static char THIS_FILE[] = __FILE__;
00013 #endif
00014
00016
00017
00018
00019 CDialogEditList::CDialogEditList(CWnd* pParent )
00020 : CDialog(CDialogEditList::IDD, pParent)
00021 {
00022
00023
00024 }
00025
00026
00027 void CDialogEditList::DoDataExchange(CDataExchange* pDX)
00028 {
00029 CDialog::DoDataExchange(pDX);
00030
00031 DDX_Control(pDX, IDC_LIST1, m_ctrlList);
00032 DDX_Control(pDX, IDC_COMBO1, m_ctrlCombo);
00033
00034 }
00035
00036
00037 BEGIN_MESSAGE_MAP(CDialogEditList, CDialog)
00038
00039 ON_BN_CLICKED(ID_ADD, OnAdd)
00040 ON_BN_CLICKED(ID_DEL, OnDel)
00041
00042 END_MESSAGE_MAP()
00043
00045
00046
00047 void CDialogEditList::OnAdd()
00048 {
00049
00050 UpdateData ();
00051 CString str;
00052 m_ctrlCombo.GetWindowText (str);
00053 if (m_ctrlList.FindStringExact (0, str)==LB_ERR)
00054 {
00055 m_ctrlList.InsertString (-1, str);
00056 }
00057 UpdateData (FALSE);
00058 }
00059
00060 BOOL CDialogEditList::OnInitDialog()
00061 {
00062 CDialog::OnInitDialog();
00063
00064 OnInit ();
00065 UpdateData ();
00066 m_ctrlCombo.SetCurSel (0);
00067 UpdateData (FALSE);
00068
00069
00070
00071 return TRUE;
00072
00073 }
00074
00075 void CDialogEditList::OnOK()
00076 {
00077
00078 OnOk ();
00079
00080 CDialog::OnOK();
00081 }
00082
00083 void CDialogEditList::OnDel()
00084 {
00085
00086 UpdateData ();
00087 if (m_ctrlList.GetSelCount())
00088 {
00089 std::vector<int> vect (m_ctrlList.GetSelCount());
00090 m_ctrlList.GetSelItems (m_ctrlList.GetSelCount(), &*vect.begin());
00091 for (int i=m_ctrlList.GetSelCount()-1; i>=0; i--)
00092 m_ctrlList.DeleteString (vect[i]);
00093 m_ctrlCombo.SetCurSel (0);
00094 }
00095 UpdateData (FALSE);
00096 }