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.

134 lines
2.5 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "utils.h"
  4. DEFINE_MODULE( "RIPREP" )
  5. INT
  6. MessageBoxFromMessageV(
  7. IN HWND Window,
  8. IN DWORD MessageId,
  9. IN BOOL SystemMessage,
  10. IN LPCTSTR CaptionString,
  11. IN UINT Style,
  12. IN va_list *Args
  13. )
  14. {
  15. TCHAR Caption[512];
  16. TCHAR Buffer[5000];
  17. if((DWORD_PTR)CaptionString > 0xffff) {
  18. //
  19. // It's a string already.
  20. //
  21. lstrcpyn(Caption,CaptionString, ARRAYSIZE(Caption));
  22. } else {
  23. //
  24. // It's a string id
  25. //
  26. if(!LoadString(g_hinstance,PtrToUlong(CaptionString),Caption, ARRAYSIZE(Caption))) {
  27. Caption[0] = 0;
  28. }
  29. }
  30. FormatMessage(
  31. SystemMessage ? FORMAT_MESSAGE_FROM_SYSTEM : FORMAT_MESSAGE_FROM_HMODULE,
  32. NULL,
  33. MessageId,
  34. 0,
  35. Buffer,
  36. ARRAYSIZE(Buffer),
  37. Args
  38. );
  39. return(MessageBox(Window,Buffer,Caption,Style));
  40. }
  41. INT
  42. MessageBoxFromMessage(
  43. IN HWND Window,
  44. IN DWORD MessageId,
  45. IN BOOL SystemMessage,
  46. IN LPCTSTR CaptionString,
  47. IN UINT Style,
  48. ...
  49. )
  50. {
  51. va_list arglist;
  52. INT i;
  53. va_start(arglist,Style);
  54. i = MessageBoxFromMessageV(Window,MessageId,SystemMessage,CaptionString,Style,&arglist);
  55. va_end(arglist);
  56. return(i);
  57. }
  58. INT
  59. MessageBoxFromMessageAndSystemError(
  60. IN HWND Window,
  61. IN DWORD MessageId,
  62. IN DWORD SystemMessageId,
  63. IN LPCTSTR CaptionString,
  64. IN UINT Style,
  65. ...
  66. )
  67. {
  68. va_list arglist;
  69. TCHAR Caption[512];
  70. TCHAR Buffer1[1024];
  71. TCHAR Buffer2[1024];
  72. INT i;
  73. //
  74. // Fetch the non-system part. The arguments are for that part of the
  75. // message -- the system part has no inserts.
  76. //
  77. va_start(arglist,Style);
  78. FormatMessage(
  79. FORMAT_MESSAGE_FROM_HMODULE,
  80. NULL,
  81. MessageId,
  82. 0,
  83. Buffer1,
  84. ARRAYSIZE(Buffer1),
  85. &arglist
  86. );
  87. va_end(arglist);
  88. //
  89. // Now fetch the system part.
  90. //
  91. FormatMessage(
  92. FORMAT_MESSAGE_FROM_SYSTEM,
  93. NULL,
  94. MessageId,
  95. 0,
  96. Buffer2,
  97. ARRAYSIZE(Buffer2),
  98. &arglist
  99. );
  100. //
  101. // Now display the message, which is made up of two parts that get
  102. // inserted into MSG_ERROR_WITH_SYSTEM_ERROR.
  103. //
  104. i = MessageBoxFromMessage(
  105. Window,
  106. MSG_ERROR_WITH_SYSTEM_ERROR,
  107. FALSE,
  108. CaptionString,
  109. Style,
  110. Buffer1,
  111. Buffer2
  112. );
  113. return(i);
  114. }