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.

143 lines
2.8 KiB

  1. #include "stdafx.h"
  2. #include "Msg.h"
  3. #include "resource.h"
  4. BOOL Msg2(
  5. UINT nIDPrompt, // nIDPrompt must indicate a string w/ ONE "%s" token in it
  6. PCTCH tsz2)
  7. {
  8. BOOL fRet = FALSE;
  9. PTCH tszOutput = NULL;
  10. try {
  11. CString str1;
  12. if (!str1.LoadString(nIDPrompt)) {
  13. // Fail to load the resource ID
  14. ASSERT(FALSE);
  15. throw 0;
  16. }
  17. // -1, %s to null-terminal, length decrease 1
  18. tszOutput = new TCHAR[str1.GetLength()+lstrlen(tsz2)-1];
  19. if (!tszOutput) {
  20. throw 0;
  21. }
  22. wsprintf(tszOutput, str1, tsz2);
  23. fRet = AfxMessageBox(tszOutput);
  24. }
  25. catch (...) {
  26. MsgOverflow();
  27. }
  28. if (tszOutput) {
  29. delete[] tszOutput;
  30. tszOutput = NULL;
  31. }
  32. return fRet;
  33. }
  34. BOOL Msg3(
  35. UINT nIDPrompt, // nIDPrompt must indicate a string w/ TWO "%s" token in it
  36. PCTCH tsz2,
  37. PCTCH tsz3)
  38. {
  39. BOOL fRet = FALSE;
  40. PTCH tszOutput = NULL;
  41. try {
  42. CString str1;
  43. if (!str1.LoadString(nIDPrompt)) {
  44. // Fail to load the resource ID
  45. ASSERT(FALSE);
  46. throw 0;
  47. }
  48. // -1, %s to null-terminal, length decrease 1
  49. tszOutput = new TCHAR[str1.GetLength()+lstrlen(tsz2)+lstrlen(tsz3)-1];
  50. if (!tszOutput) {
  51. throw 0;
  52. }
  53. wsprintf(tszOutput, str1, tsz2, tsz3);
  54. fRet = AfxMessageBox(tszOutput);
  55. }
  56. catch (...) {
  57. MsgOverflow();
  58. }
  59. if (tszOutput) {
  60. delete[] tszOutput;
  61. tszOutput = NULL;
  62. }
  63. return fRet;
  64. }
  65. BOOL MsgOverflow(void)
  66. {
  67. return AfxMessageBox(IDS_MEMOVERFLOW);
  68. }
  69. BOOL MsgUnrecognizedFileType(
  70. PCTCH tszSrc)
  71. {
  72. return Msg2(IDS_UNRECFILETYPE, tszSrc);
  73. }
  74. BOOL MsgUsage(void)
  75. {
  76. return AfxMessageBox(IDS_USEAGE);
  77. }
  78. BOOL MsgFailToBackupFile(
  79. PCTCH tszSrc,
  80. PCTCH tszBack)
  81. {
  82. return Msg3(IDS_COPYFAIL, tszSrc, tszBack);
  83. }
  84. BOOL MsgOpenSourceFileError(
  85. PCTCH tszSrc)
  86. {
  87. return Msg2(IDS_OPENSOURCEFILEFAIL, tszSrc);
  88. }
  89. BOOL MsgTargetFileExist(
  90. PCTCH tszTar)
  91. {
  92. return Msg2(IDS_TARGETFILEEXIST, tszTar);
  93. }
  94. BOOL MsgWriteFileError(void)
  95. {
  96. return AfxMessageBox(IDS_WRITEFILEERROR);
  97. }
  98. BOOL MsgNotUnicodeTextSourceFile(void)
  99. {
  100. return AfxMessageBox(IDS_NOTUNICODETEXTFILE);
  101. }
  102. BOOL MsgNotAnsiTextSourceFile(void)
  103. {
  104. return AfxMessageBox(IDS_NOTANSITEXTFILE);
  105. }
  106. BOOL MsgNotRtfSourceFile(void)
  107. {
  108. return AfxMessageBox(IDS_NOTRTFFILE);
  109. }
  110. BOOL MsgConvertFail(void)
  111. {
  112. return AfxMessageBox(IDS_CONVERTFAIL);
  113. }
  114. BOOL MsgConvertFinish(void)
  115. {
  116. return AfxMessageBox(IDS_CONVERTFINISH, MB_OK|MB_ICONINFORMATION);
  117. }