home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / LISTDLG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-10  |  1.8 KB  |  81 lines

  1. // listdlg.cpp : implementation file
  2. // Copyright (C) 1996 LEAD Technologies, Inc.
  3. // All rights reserved.
  4.  
  5. #include "stdafx.h"
  6. #include "mfcdemo.h"
  7. #include "listdlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CListDlg dialog
  16.  
  17.  
  18. CListDlg::CListDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CListDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CListDlg)
  22.         m_nValue = 0;
  23.     m_strLabel = _T("");
  24.     m_strTitle = _T("");
  25.     m_strInit = _T("");
  26.     //}}AFX_DATA_INIT
  27. }
  28.  
  29.  
  30. void CListDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32.     CDialog::DoDataExchange(pDX);
  33.     //{{AFX_DATA_MAP(CListDlg)
  34.     DDX_Control(pDX, IDC_LIST1, m_List);
  35.     DDX_Text(pDX, IDC_STATIC1, m_strLabel);
  36.     //}}AFX_DATA_MAP
  37. }
  38.  
  39.  
  40. BEGIN_MESSAGE_MAP(CListDlg, CDialog)
  41.     //{{AFX_MSG_MAP(CListDlg)
  42.     ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  43.     ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
  44.     //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46.  
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CListDlg message handlers
  50.  
  51. BOOL CListDlg::OnInitDialog() 
  52. {
  53.     CDialog::OnInitDialog();
  54.         SetWindowText(m_strTitle);
  55.         int j = 0;
  56.         for(int i = 0; i < m_strInit.GetLength(); i++)
  57.         {
  58.                 if(m_strInit[i] == '|')
  59.                 {
  60.                         m_List.AddString(m_strInit.Mid(j, i - j));
  61.                         j = i + 1;
  62.                 }
  63.         }
  64.         m_List.SetCurSel(m_nValue);
  65.     // TODO: Add extra initialization here
  66.     
  67.     return TRUE;  // return TRUE unless you set the focus to a control
  68.                   // EXCEPTION: OCX Property Pages should return FALSE
  69. }
  70.  
  71. void CListDlg::OnSelchangeList1() 
  72. {
  73.         m_nValue = m_List.GetCurSel();
  74.     
  75. }
  76.  
  77. void CListDlg::OnDblclkList1() 
  78. {
  79.         OnOK();
  80. }
  81.