Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.5 KiB

4 years ago
  1. // wininc.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #pragma hdrstop
  6. #include "wininc.h"
  7. #include "include.h"
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CWindowInclude dialog
  14. CWindowInclude::CWindowInclude(CTable** pptblInclude, PCSTR pszBaseFile,
  15. CWnd* pParent /*=NULL*/)
  16. : CDialog(CWindowInclude::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CWindowInclude)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. ASSERT(pptblInclude);
  22. m_pptblInclude = pptblInclude;
  23. m_fChanged = FALSE;
  24. m_pszBaseFile = pszBaseFile;
  25. }
  26. void CWindowInclude::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CWindowInclude)
  30. // NOTE: the ClassWizard will add DDX and DDV calls here
  31. //}}AFX_DATA_MAP
  32. m_plist = (CListBox *) GetDlgItem(IDC_LIST1);
  33. ASSERT(m_plist);
  34. if (!pDX->m_bSaveAndValidate) { // initialization
  35. if (*m_pptblInclude) {
  36. FillListFromTable(*m_pptblInclude, m_plist, FALSE);
  37. m_plist->SetCurSel(0);
  38. }
  39. else
  40. GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);
  41. }
  42. else if (m_fChanged) // save settings
  43. FillTableFromList(m_pptblInclude, m_plist);
  44. }
  45. BEGIN_MESSAGE_MAP(CWindowInclude, CDialog)
  46. //{{AFX_MSG_MAP(CWindowInclude)
  47. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  48. ON_BN_CLICKED(IDC_BUTTON_OVERVIEW, OnButtonOverview)
  49. ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CWindowInclude message handlers
  54. void CWindowInclude::OnButtonAdd()
  55. {
  56. CString cszFile;
  57. CInclude addinc(m_pszBaseFile, &cszFile, this);
  58. if (addinc.DoModal() == IDOK) {
  59. // Add the item and select it.
  60. int nItem = m_plist->AddString(cszFile);
  61. m_plist->SetCurSel(nItem);
  62. // Enable the Remove button if it isn't already.
  63. if (!nItem)
  64. GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);
  65. m_fChanged = TRUE;
  66. }
  67. }
  68. void CWindowInclude::OnButtonOverview()
  69. {
  70. HelpOverview(m_hWnd, IDH_BAS_WINDOW_INCLUDE);
  71. }
  72. void CWindowInclude::OnButtonRemove()
  73. {
  74. // Delete the selected item: there should be one or we'd be disabled.
  75. int nSel = m_plist->GetCurSel();
  76. ASSERT(nSel != LB_ERR);
  77. m_plist->DeleteString(nSel);
  78. // Select the next item or disable the Remove button.
  79. int nCount = m_plist->GetCount();
  80. if (nCount)
  81. m_plist->SetCurSel(nSel < nCount ? nSel : nCount - 1);
  82. else
  83. GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);
  84. m_fChanged = TRUE;
  85. }