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.

138 lines
3.3 KiB

  1. /*****************************************************************************************************************
  2. FILENAME: DlgAnl.cpp
  3. COPYRIGHT 2001 Microsoft Corporation and Executive Software International, Inc.
  4. */
  5. #include "stdafx.h"
  6. #ifndef SNAPIN
  7. #ifndef NOWINDOWSH
  8. #include <windows.h>
  9. #endif
  10. #endif
  11. #include "DfrgUI.h"
  12. #include "DfrgCmn.h"
  13. #include "DfrgCtl.h"
  14. #include "resource.h"
  15. #include "DlgRpt.h"
  16. #include "DlgAnl.h"
  17. #include "GetDfrgRes.h"
  18. #include "DfrgHlp.h"
  19. #include "VolList.h"
  20. #include "genericdialog.h"
  21. static CVolume *pLocalVolume = NULL;
  22. static HFONT hDlgFont = NULL;
  23. /*****************************************************************************************************************
  24. COPYRIGHT 2001 Microsoft Corporation and Executive Software International, Inc.
  25. ROUTINE DESCRIPTION:
  26. Raises the Analyze Complete dialog
  27. GLOBAL VARIABLES:
  28. None
  29. INPUT:
  30. IN pVolume - address of volume that has just completed Analyzing
  31. RETURN:
  32. TRUE - Worked OK
  33. FALSE - Failure
  34. */
  35. BOOL RaiseAnalyzeDoneDialog(
  36. CVolume *pVolume
  37. )
  38. {
  39. pLocalVolume = pVolume;
  40. VString dlgString;
  41. UINT iWhichKeyPressed = NULL;
  42. CGenericDialog* genericdialog = new CGenericDialog();
  43. if (!genericdialog) {
  44. return FALSE;
  45. }
  46. genericdialog->SetTitle(IDS_LABEL_ANALYSIS_COMPLETE);
  47. //close button 0
  48. genericdialog->SetButtonText(0,IDS_CLOSE);
  49. //defrag button 1
  50. genericdialog->SetButtonText(1,IDS_DEFRAGMENT);
  51. //view report 2
  52. genericdialog->SetButtonText(2,IDS_REPORT);
  53. //get the string displayed in the dialog
  54. dlgString.Empty();
  55. dlgString += GetDialogBoxTextAnl(pLocalVolume);
  56. genericdialog->SetText(dlgString.GetBuffer());
  57. //set the help context IDs
  58. genericdialog->SetButtonHelp(0, IDH_106_2);
  59. genericdialog->SetButtonHelp(1, IDH_106_201);
  60. genericdialog->SetButtonHelp(2, IDH_106_205);
  61. genericdialog->SetHelpFilePath();
  62. iWhichKeyPressed = genericdialog->DoModal(pLocalVolume->m_pDfrgCtl->m_hWndCD);
  63. delete genericdialog;
  64. switch(iWhichKeyPressed) {
  65. case 0:
  66. break;
  67. case 1:
  68. pLocalVolume->Defragment();
  69. break;
  70. case 2:
  71. if(pLocalVolume->EngineState() == ENGINE_STATE_IDLE){
  72. // close the dialog
  73. // raise the report dialog
  74. RaiseReportDialog(pLocalVolume);
  75. }
  76. break;
  77. default:
  78. return FALSE;
  79. }
  80. return TRUE;
  81. }
  82. VString GetDialogBoxTextAnl(CVolume *pVolume)
  83. {
  84. // write the Analysis Complete text in the dialog
  85. VString dlgText(IDS_ANALYSIS_COMPLETE_FOR, GetDfrgResHandle());
  86. dlgText += TEXT(" ");
  87. dlgText += pLocalVolume->DisplayLabel();
  88. dlgText += TEXT("\r");
  89. dlgText += TEXT("\n");
  90. dlgText += TEXT("\r");
  91. dlgText += TEXT("\n");
  92. //If the fragmentation on the disk exceeds 10% fragmentation, then recommend defragging.
  93. int percentFragged = ((int)pLocalVolume->m_TextData.PercentDiskFragged +
  94. (int)pLocalVolume->m_TextData.FreeSpaceFragPercent) / 2;
  95. VString userMsg;
  96. if(percentFragged > 10){
  97. userMsg.LoadString(IDS_LABEL_CHOOSE_DEFRAGMENT, GetDfrgResHandle());
  98. }
  99. //Otherwise tell the user he doesn't need to defragment at this time.
  100. else{
  101. userMsg.LoadString(IDS_LABEL_NO_CHOOSE_DEFRAGMENT, GetDfrgResHandle());
  102. }
  103. dlgText += userMsg;
  104. return(dlgText);
  105. }