home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 1 / WINDOWS95_1.bin / internet / vogon / slides.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-02  |  4.0 KB  |  136 lines

  1. // slides.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vogon.h"
  6. #include "slides.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CSlideShowDlg dialog
  15.  
  16.  
  17. CSlideShowDlg::CSlideShowDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CSlideShowDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CSlideShowDlg)
  21.     m_uintInterval = 10;
  22.     m_doLoop = FALSE;
  23.     m_stringSlideName = _T("");
  24.     //}}AFX_DATA_INIT
  25. }
  26.  
  27.  
  28. void CSlideShowDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(CSlideShowDlg)
  32.     DDX_Control(pDX, IDC_LIST_SLIDES, m_listboxSlides);
  33.     DDX_Control(pDX, IDC_EDIT_SLIDE_NAME, m_editSlideName);
  34.     DDX_Text(pDX, IDC_EDIT_INTERVAL, m_uintInterval);
  35.     DDV_MinMaxUInt(pDX, m_uintInterval, 1, 38400);
  36.     DDX_Check(pDX, IDC_CHECK_LOOP, m_doLoop);
  37.     DDX_Text(pDX, IDC_EDIT_SLIDE_NAME, m_stringSlideName);
  38.     //}}AFX_DATA_MAP
  39. }
  40.  
  41.  
  42. BEGIN_MESSAGE_MAP(CSlideShowDlg, CDialog)
  43.     //{{AFX_MSG_MAP(CSlideShowDlg)
  44.     ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  45.     ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
  46.     ON_LBN_SELCHANGE(IDC_LIST_SLIDES, OnSelChangeListSlides)
  47.     //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49.  
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CSlideShowDlg message handlers
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. //
  56. BOOL CSlideShowDlg::OnInitDialog() 
  57. {
  58.    CDialog::OnInitDialog();
  59.    // Load the list box:
  60.    for (int i = 0; i <= m_pSlideList->GetUpperBound(); i++)
  61.    {  // Add the slide to the list
  62.       m_listboxSlides.AddString(m_pSlideList->GetAt(i));
  63.    }
  64.    // TODO: Add extra initialization here
  65.    return TRUE;  // return TRUE unless you set the focus to a control
  66.                  // EXCEPTION: OCX Property Pages should return FALSE
  67. }
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. //
  71. void CSlideShowDlg::OnOK() 
  72. {
  73.     CDialog::OnOK();
  74.    // Empty the URL list
  75.    m_pSlideList->RemoveAll();
  76.    // Unload the list box:
  77.    for (int i = 0; i < m_listboxSlides.GetCount(); i++)
  78.    {  // Get the slide from the list
  79.       CString stringText;
  80.       m_listboxSlides.GetText(i, stringText);
  81.       // Add the URL to the string array
  82.       m_pSlideList->Add(stringText);
  83.    }
  84. }
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. //
  88. void CSlideShowDlg::OnButtonAdd() 
  89. {  // Add the string in the edit control
  90.    CString stringText;
  91.    // Get the text
  92.    m_editSlideName.GetWindowText(stringText);
  93.    // Avoid empty strings
  94.    if (!stringText.IsEmpty())
  95.    {  // Add it to the list box
  96.       m_listboxSlides.AddString(stringText);
  97.    }
  98. }
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. //
  102. void CSlideShowDlg::OnButtonRemove() 
  103. {  // Remove the highlighted strings: how many ?
  104.    int size = m_listboxSlides.GetCount();
  105.    if (size)
  106.    {  // Have some items to remove: allocate index space
  107.       LPINT pIndices = new int[size];
  108.       // Get the indices
  109.       int countSel = m_listboxSlides.GetSelItems(size, pIndices);
  110.       // Delete items backwards to avoid index perturbration
  111.       while (--countSel >= 0)
  112.       {  // Delete the selected item:
  113.          m_listboxSlides.DeleteString(pIndices[countSel]);
  114.       }
  115.       // Done with the indices
  116.       delete [] pIndices;
  117.    }
  118.    // Clear out the edit box, nothing selected any more ..
  119.    m_editSlideName.SetWindowText(_T(""));
  120. }
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123. //
  124. void CSlideShowDlg::OnSelChangeListSlides() 
  125. {  // Just get the first selected item
  126.    int index;
  127.    int countSel = m_listboxSlides.GetSelItems(1, &index);
  128.    if (countSel)
  129.    {  // Get the item
  130.       CString stringText;
  131.       m_listboxSlides.GetText(index, stringText);
  132.       // Copy to the edit control
  133.       m_editSlideName.SetWindowText(stringText);
  134.    }
  135. }
  136.