Source code of Windows XP (NT5)
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.

166 lines
3.8 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. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CSaveTemplates message handlers
  44. void CSaveTemplates::OnOK()
  45. {
  46. CString strInfFile;
  47. CString strComputerTemplate;
  48. PEDITTEMPLATE pet = 0;
  49. int nCount = m_lbTemplates.GetCount();
  50. while(nCount--)
  51. {
  52. if (m_lbTemplates.GetSel(nCount) == 0)
  53. {
  54. //
  55. // Item isn't selected, so don't save it
  56. //
  57. continue;
  58. }
  59. pet = (PEDITTEMPLATE)m_lbTemplates.GetItemData( nCount );
  60. if (pet) {
  61. //
  62. // We found the template in our inf file cache
  63. // so save it
  64. //
  65. pet->Save();
  66. }
  67. }
  68. CDialog::OnOK();
  69. }
  70. void CSaveTemplates::OnCancel()
  71. {
  72. CDialog::OnCancel();
  73. }
  74. /*
  75. void CSaveTemplates::OnSaveSel()
  76. {
  77. int nCount;
  78. CString strInfFile;
  79. PEDITTEMPLATE pet;
  80. nCount = m_lbTemplates.GetCount();
  81. while(nCount--) {
  82. if (m_lbTemplates.GetSel(nCount) > 0) {
  83. m_lbTemplates.GetText(nCount,strInfFile);
  84. //pet = (PEDITTEMPLATE) m_lbTemplates.GetItemDataPtr(nCount);
  85. m_Templates.Lookup(strInfFile,pet);
  86. pet->Save(strInfFile);
  87. // pet->bDirty = false;
  88. // SceWriteSecurityProfileInfo(strInfFile,AREA_ALL,pet->pTemplate,NULL);
  89. m_lbTemplates.DeleteString(nCount);
  90. }
  91. }
  92. CDialog::OnOK();
  93. }
  94. void CSaveTemplates::OnSelchangeTemplateList()
  95. {
  96. if (m_lbTemplates.GetSelCount() > 0) {
  97. m_btnSaveSel.EnableWindow(TRUE);
  98. } else {
  99. m_btnSaveSel.EnableWindow(FALSE);
  100. }
  101. }
  102. */
  103. void CSaveTemplates::AddTemplate(LPCTSTR szInfFile, PEDITTEMPLATE pet)
  104. {
  105. CString strInfFile;
  106. //
  107. // Special template. Do not save.
  108. //
  109. if (pet->QueryNoSave()) {
  110. return;
  111. }
  112. //
  113. // Display the template's friendly name
  114. //
  115. CString strL = pet->GetFriendlyName();
  116. if (strL.IsEmpty()) {
  117. strL = szInfFile;
  118. }
  119. strL.MakeLower();
  120. m_Templates.SetAt(strL,pet);
  121. }
  122. BOOL CSaveTemplates::OnInitDialog()
  123. {
  124. CDialog::OnInitDialog();
  125. POSITION pos = m_Templates.GetStartPosition();
  126. PEDITTEMPLATE pTemplate = 0;
  127. CString szKey;
  128. while(pos)
  129. {
  130. m_Templates.GetNextAssoc(pos,szKey,pTemplate);
  131. int iIndex = m_lbTemplates.AddString( pTemplate->GetFriendlyName() );
  132. m_lbTemplates.SetItemData( iIndex, (LPARAM)pTemplate );
  133. }
  134. m_lbTemplates.SelItemRange(TRUE,0,m_lbTemplates.GetCount());
  135. RECT temprect; //HScroll to see full template name
  136. m_lbTemplates.GetWindowRect(&temprect);
  137. m_lbTemplates.SetHorizontalExtent((temprect.right-temprect.left)*6);
  138. return TRUE; // return TRUE unless you set the focus to a control
  139. // EXCEPTION: OCX Property Pages should return FALSE
  140. }