Leaked source code of windows server 2003
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.

148 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: savetemp.cpp
  7. //
  8. // Contents: implementation of CSaveTemplates
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "resource.h"
  14. #include "snapmgr.h"
  15. #include "SaveTemp.h"
  16. #include "util.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CSaveTemplates dialog
  24. CSaveTemplates::CSaveTemplates(CWnd* pParent /*=NULL*/)
  25. : CHelpDialog(a186HelpIDs, IDD, pParent)
  26. {
  27. //{{AFX_DATA_INIT(CSaveTemplates)
  28. // NOTE: the ClassWizard will add member initialization here
  29. //}}AFX_DATA_INIT
  30. }
  31. void CSaveTemplates::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CDialog::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CSaveTemplates)
  35. DDX_Control(pDX, IDC_TEMPLATE_LIST, m_lbTemplates);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(CSaveTemplates, CHelpDialog)
  39. //{{AFX_MSG_MAP(CSaveTemplates)
  40. ON_LBN_SELCHANGE(IDC_TEMPLATE_LIST, OnSelchangeTemplateList)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CSaveTemplates message handlers
  45. void CSaveTemplates::OnOK()
  46. {
  47. CString strInfFile;
  48. CString strComputerTemplate;
  49. PEDITTEMPLATE pet = 0;
  50. int nCount = m_lbTemplates.GetCount();
  51. while(nCount--)
  52. {
  53. if (m_lbTemplates.GetSel(nCount) == 0)
  54. {
  55. //
  56. // Item isn't selected, so don't save it
  57. //
  58. continue;
  59. }
  60. pet = (PEDITTEMPLATE)m_lbTemplates.GetItemData( nCount );
  61. if (pet) {
  62. //
  63. // We found the template in our inf file cache
  64. // so save it
  65. //
  66. pet->Save();
  67. }
  68. }
  69. CDialog::OnOK();
  70. }
  71. void CSaveTemplates::OnCancel()
  72. {
  73. CDialog::OnCancel();
  74. }
  75. //Raid #668724, yanggao, 8/9/2002
  76. void CSaveTemplates::OnSelchangeTemplateList()
  77. {
  78. if (m_lbTemplates.GetSelCount() > 0)
  79. {
  80. GetDlgItem(IDOK)->EnableWindow(TRUE);
  81. }
  82. else
  83. {
  84. GetDlgItem(IDOK)->EnableWindow(FALSE);
  85. }
  86. }
  87. void CSaveTemplates::AddTemplate(LPCTSTR szInfFile, PEDITTEMPLATE pet)
  88. {
  89. CString strInfFile;
  90. //
  91. // Special template. Do not save.
  92. //
  93. if (pet->QueryNoSave()) {
  94. return;
  95. }
  96. //
  97. // Display the template's friendly name
  98. //
  99. CString strL = pet->GetFriendlyName();
  100. if (strL.IsEmpty()) {
  101. strL = szInfFile;
  102. }
  103. strL.MakeLower();
  104. m_Templates.SetAt(strL,pet);
  105. }
  106. BOOL CSaveTemplates::OnInitDialog()
  107. {
  108. CDialog::OnInitDialog();
  109. POSITION pos = m_Templates.GetStartPosition();
  110. PEDITTEMPLATE pTemplate = 0;
  111. CString szKey;
  112. while(pos)
  113. {
  114. m_Templates.GetNextAssoc(pos,szKey,pTemplate);
  115. int iIndex = m_lbTemplates.AddString( pTemplate->GetFriendlyName() );
  116. m_lbTemplates.SetItemData( iIndex, (LPARAM)pTemplate );
  117. }
  118. m_lbTemplates.SelItemRange(TRUE,0,m_lbTemplates.GetCount());
  119. RECT temprect; //HScroll to see full template name
  120. m_lbTemplates.GetWindowRect(&temprect);
  121. m_lbTemplates.SetHorizontalExtent((temprect.right-temprect.left)*6);
  122. return TRUE; // return TRUE unless you set the focus to a control
  123. // EXCEPTION: OCX Property Pages should return FALSE
  124. }