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.

82 lines
2.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C A T L U I . C P P
  7. //
  8. // Contents: UI common code relying on ATL.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 13 Oct 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.h>
  16. #pragma hdrstop
  17. #include <atlbase.h>
  18. extern CComModule _Module; // required by atlcom.h
  19. #include <atlcom.h>
  20. #ifdef SubclassWindow
  21. #undef SubclassWindow
  22. #endif
  23. #include <atlwin.h>
  24. #include "ncatlui.h"
  25. #include "ncatl.h"
  26. #include "ncstring.h"
  27. //+---------------------------------------------------------------------------
  28. //
  29. // Function: NcMsgBox
  30. //
  31. // Purpose: Displays a message box using resource strings and replaceable
  32. // parameters.
  33. //
  34. // Arguments:
  35. // hwnd [in] parent window handle
  36. // unIdCaption [in] resource id of caption string
  37. // unIdFormat [in] resource id of text string (with %1, %2, etc.)
  38. // unStyle [in] standard message box styles
  39. // ... [in] replaceable parameters (optional)
  40. // (these must be LPCWSTRs as that is all
  41. // FormatMessage handles.)
  42. //
  43. // Returns: the return value of MessageBox()
  44. //
  45. // Author: shaunco 24 Mar 1997
  46. //
  47. // Notes: FormatMessage is used to do the parameter substitution.
  48. //
  49. NOTHROW
  50. int
  51. WINAPIV
  52. NcMsgBox (
  53. HWND hwnd,
  54. UINT unIdCaption,
  55. UINT unIdFormat,
  56. UINT unStyle,
  57. ...)
  58. {
  59. PCWSTR pszCaption = SzLoadIds(unIdCaption);
  60. PCWSTR pszFormat = SzLoadIds(unIdFormat);
  61. PWSTR pszText = NULL;
  62. va_list val;
  63. va_start (val, unStyle);
  64. FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
  65. pszFormat, 0, 0, (PWSTR)&pszText, 0, &val);
  66. va_end (val);
  67. if(!pszText)
  68. {
  69. // This is what MessageBox returns if it fails.
  70. return 0;
  71. }
  72. int nRet = MessageBox (hwnd, pszText, pszCaption, unStyle);
  73. LocalFree (pszText);
  74. return nRet;
  75. }