home *** CD-ROM | disk | FTP | other *** search
- // DaoTableSelectDlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "DynaList.h"
- #include "TbSelDlg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CDaoTableSelectDlg dialog
-
-
- CDaoTableSelectDlg::CDaoTableSelectDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDaoTableSelectDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDaoTableSelectDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
-
-
- void CDaoTableSelectDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDaoTableSelectDlg)
- DDX_Control(pDX, IDC_TABLELIST, m_ctlTableList);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CDaoTableSelectDlg, CDialog)
- //{{AFX_MSG_MAP(CDaoTableSelectDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CDaoTableSelectDlg message handlers
-
- BOOL CDaoTableSelectDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- if(!m_pDatabase->IsOpen())
- {
- CButton* pOK = (CButton*)GetDlgItem(IDOK);
- pOK->EnableWindow(FALSE);
- return TRUE;
- }
-
- // Fill the listbox with the table names
- CDaoTableDefInfo tdi;
- int nTables = m_pDatabase->GetTableDefCount();
- for(int i = 0; i < nTables; i++)
- {
- m_pDatabase->GetTableDefInfo(i, tdi);
- m_ctlTableList.AddString(tdi.m_strName);
- }
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
-
- void CDaoTableSelectDlg::OnOK()
- {
- // Extract the table selections and place in member variable
- m_strTables = "";
- int nSelCount = m_ctlTableList.GetSelCount();
- if(nSelCount > 0)
- {
- int* pIndex = new int[nSelCount];
- m_ctlTableList.GetSelItems(nSelCount, pIndex);
- m_ctlTableList.GetText(*pIndex, m_strTables);
- for(int i = 1; i < nSelCount; i++)
- {
- CString strText;
- m_ctlTableList.GetText(*(pIndex + i), strText);
- m_strTables += ", ";
- m_strTables += strText;
- }
-
- delete [] pIndex;
- }
- CDialog::OnOK();
- }
-