SelDlg.cpp
上传用户:hzwailv
上传日期:2010-01-09
资源大小:405k
文件大小:2k
- // SelDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "MapDemo.h"
- #include "SelDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSelLayerDlg dialog
- CSelLayerDlg::CSelLayerDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSelLayerDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSelLayerDlg)
- m_strListBox = _T("");
- m_strLayer = _T("");
- //}}AFX_DATA_INIT
- m_pMapX=NULL;
- }
- CSelLayerDlg::CSelLayerDlg(CMapX* pMapX,CWnd* pParent /*=NULL*/)
- : CDialog(CSelLayerDlg::IDD, pParent)
- {
- m_strListBox = _T("");
- m_strLayer = _T("");
- m_pMapX=pMapX;
- }
- void CSelLayerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSelLayerDlg)
- DDX_Control(pDX, IDC_LIST_LAYERDLG, m_listBox);
- DDX_LBString(pDX, IDC_LIST_LAYERDLG, m_strListBox);
- DDX_Text(pDX, IDC_STATIC_LAYERNAME, m_strLayer);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSelLayerDlg, CDialog)
- //{{AFX_MSG_MAP(CSelLayerDlg)
- ON_LBN_SELCHANGE(IDC_LIST_LAYERDLG, OnSelchangeListLayerdlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSelLayerDlg message handlers
- BOOL CSelLayerDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- if(m_pMapX==NULL) return TRUE;
- CMapXLayers layers=m_pMapX->GetLayers();
- int nIndex=-1;
- for(int i=0;i<layers.GetCount();i++)
- {
- CMapXLayer layer=layers.Item(i+1);
- CString strName=layer.GetName();
- m_listBox.AddString(strName);
- if(m_strLayer==strName) nIndex=i;
- }
-
- m_listBox.SetCurSel(nIndex);
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CSelLayerDlg::OnSelchangeListLayerdlg()
- {
- UpdateData(TRUE);
- m_strLayer=m_strListBox;
- UpdateData(FALSE);
- }
- CString CSelLayerDlg::GetEditLayerName()
- {
- return m_strLayer;
- }
- void CSelLayerDlg::SetEditLayerName(CString str)
- {
- m_strLayer=str;
- }
- void CSelLayerDlg::OnOK()
- {
- if(m_pMapX!=NULL){
- UpdateData(FALSE);
- CMapXLayers layers=m_pMapX->GetLayers();
- CMapXLayer layer=layers.Item(m_strLayer);
- if(layer.GetEditable())
- layer.SetEditable(TRUE);
-
- }
-
- CDialog::OnOK();
- }