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.

155 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. msgi.h
  5. Abstract:
  6. Message box routines
  7. Author:
  8. Vlad Sadovsky (vlads) 26-Jan-1997
  9. Revision History:
  10. 26-Jan-1997 VladS created
  11. --*/
  12. #include "cplusinc.h"
  13. #include "sticomm.h"
  14. extern HINSTANCE g_hInstance;
  15. int MsgBox( HWND hwndOwner, UINT idMsg, UINT wFlags, const TCHAR *aps[] /* = NULL */ )
  16. {
  17. STR strTitle;
  18. STR strMsg;
  19. strTitle.LoadString(IDS_MSGTITLE);
  20. if (aps == NULL)
  21. strMsg.LoadString( idMsg );
  22. else
  23. strMsg.FormatString(idMsg,aps);
  24. return ::MessageBox( hwndOwner, strMsg.QueryStr(), strTitle.QueryStr(), wFlags | MB_SETFOREGROUND );
  25. }
  26. /*
  27. * MsgBoxPrintf
  28. * ------------
  29. *
  30. * Message box routine
  31. *
  32. */
  33. UINT MsgBoxPrintf(HWND hwnd,UINT uiMsg,UINT uiTitle,UINT uiFlags,...)
  34. {
  35. STR strTitle;
  36. STR strMessage;
  37. LPTSTR lpFormattedMessage = NULL;
  38. UINT err;
  39. va_list start;
  40. va_start(start,uiFlags);
  41. strMessage.LoadString(uiMsg);
  42. err = ::FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
  43. (LPVOID)strMessage.QueryStr(),
  44. // FORMAT_MESSAGE_FROM_HMODULE,
  45. //::g_hmodThisDll,
  46. uiMsg, // Message resource id
  47. NULL, // Language id
  48. (LPTSTR)&lpFormattedMessage, // Return pointer to fromatted text
  49. 255, // Min.length
  50. &start
  51. );
  52. if (!err || !lpFormattedMessage) {
  53. err = GetLastError();
  54. return err;
  55. }
  56. strTitle.LoadString(uiTitle);
  57. err = ::MessageBox(hwnd,
  58. lpFormattedMessage,
  59. strTitle.QueryStr(),
  60. uiFlags);
  61. ::LocalFree(lpFormattedMessage);
  62. return err;
  63. }
  64. #if 0
  65. /*
  66. * LoadMsgPrintf
  67. * -------------
  68. *
  69. * Uses normal printf style format string
  70. */
  71. UINT
  72. LoadMsgPrintf(
  73. NLS_STR& nlsMessage,
  74. UINT uiMsg,
  75. ...
  76. )
  77. {
  78. LPSTR lpFormattedMessage = NULL;
  79. UINT err;
  80. va_list start;
  81. va_start(start,uiMsg);
  82. nlsMessage.LoadString(uiMsg);
  83. #ifdef USE_PRINTF_STYLE
  84. lpFormattedMessage = ::LocalAlloc(GPTR,255); // BUGBUG
  85. if (!lpFormattedMessage) {
  86. Break();
  87. return WN_OUT_OF_MEMORY;
  88. }
  89. ::wsprintf(lpFormattedMessage,
  90. nlsMessage.QueryPch(),
  91. &start);
  92. #else
  93. err = ::FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER,
  94. nlsMessage,
  95. //| FORMAT_MESSAGE_FROM_HMODULE,
  96. //::g_hmodThisDll,
  97. uiMsg, // Message resource id
  98. NULL, // Language id
  99. (LPTSTR)&lpFormattedMessage, // Return pointer to fromatted text
  100. 255, // Min.length
  101. &start
  102. );
  103. if (!err || !lpFormattedMessage) {
  104. err = GetLastError();
  105. return err;
  106. }
  107. #endif
  108. nlsMessage = lpFormattedMessage;
  109. ::LocalFree(lpFormattedMessage);
  110. return WN_SUCCESS;
  111. }
  112. #endif