// EquipSelDlg.cpp : 实现文件 // #include "stdafx.h" #include "EquipSelDlg.h" // CEquipSelDlg 对话框 IMPLEMENT_DYNAMIC(CEquipSelDlg, CDialog) CEquipSelDlg::CEquipSelDlg(CWnd* pParent /*=NULL*/) : CDialog(CEquipSelDlg::IDD, pParent) { } CEquipSelDlg::~CEquipSelDlg() { } void CEquipSelDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LISTBOX, m_wndListBox); } BEGIN_MESSAGE_MAP(CEquipSelDlg, CDialog) ON_BN_CLICKED(IDOK, &CEquipSelDlg::OnBnClickedOk) ON_LBN_SELCHANGE(IDC_LISTBOX, &CEquipSelDlg::OnLbnSelchangeListbox) END_MESSAGE_MAP() void CEquipSelDlg::SetNames(CStringArray& arNames,AcDbObjectIdArray& arids) { m_arNames.Append(arNames); m_nCurSel = 0; m_arids.append(arids); } int CEquipSelDlg::GetNameIndex() { return m_nCurSel; } BOOL CEquipSelDlg::OnInitDialog() { CDialog::OnInitDialog(); for (int i = 0;i < m_arNames.GetSize();i++) { m_wndListBox.InsertString(i,m_arNames.GetAt(i)); } return TRUE; } void CEquipSelDlg::OnBnClickedOk() { m_nCurSel = m_wndListBox.GetCurSel(); OnOK(); } void CEquipSelDlg::OnLbnSelchangeListbox() { m_nCurSel = m_wndListBox.GetCurSel(); if (m_nCurSel != -1) { ads_name ssPick,ent; acdbGetAdsName(ent, m_arids.at(m_nCurSel)); acedSSAdd(ent, NULL, ssPick); acedGetAcadDwgView()->SetFocus(); acedSSSetFirst(ssPick, ssPick); acedSSFree(ssPick); acedUpdateDisplay(); } }