// GenericPopupList.cpp : implementation file // #include "stdafx.h" #include "sp.h" #include "GenericPopupList.h" #include "StringParser.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGenericPopupList dialog CGenericPopupList::CGenericPopupList(CWnd* pParent /*=NULL*/) : CDialog(CGenericPopupList::IDD, pParent) { //{{AFX_DATA_INIT(CGenericPopupList) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CGenericPopupList::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CGenericPopupList) DDX_Control(pDX, IDC_BTNOPEN, m_btnOpen); DDX_Control(pDX, IDC_BTNEXIT, m_btnExit); DDX_Control(pDX, IDC_LSTNBRECS, m_lb); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CGenericPopupList, CDialog) //{{AFX_MSG_MAP(CGenericPopupList) ON_LBN_DBLCLK(IDC_LSTNBRECS, OnDblclkLstnbrecs) ON_BN_CLICKED(IDC_BTNEXIT, OnBtnexit) ON_BN_CLICKED(IDC_BTNOPEN, OnBtnopen) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGenericPopupList message handlers void CGenericPopupList::OnDblclkLstnbrecs() { CString strSelected; strSelected=m_lb.GetSelectedItem(0); m_pSelectedID->Format("%s",strSelected); CDialog::OnOK(); } void CGenericPopupList::OnBtnopen() { OnDblclkLstnbrecs(); } void CGenericPopupList::OnBtnexit() { m_pSelectedID->Empty(); CDialog::OnOK(); } void CGenericPopupList::OnOK() {} BOOL CGenericPopupList::OnInitDialog() { CDialog::OnInitDialog(); CString strData,strIndex; //Fill list box from m_LbData CStringParser sp(m_strLbData,','); int nCount=sp.GetCount(); if (nCount > 0) { for (int i = 1; i <= nCount; i+=2) { strData = sp.GetField(i); strIndex=sp.GetField(i+1); m_lb.AddRow(strData,strIndex); } } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }