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.

102 lines
2.7 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /* NPGENERR.C -- Implementation of the DisplayGenericError subroutine.
  6. *
  7. * History:
  8. * 10/07/93 gregj Created
  9. */
  10. #include "npcommon.h"
  11. #include "npmsg.h"
  12. #include "npstring.h"
  13. /*******************************************************************
  14. NAME: DisplayGenericError
  15. SYNOPSIS: Displays an error message, substituting in a
  16. description of an error code.
  17. ENTRY: hwnd - parent window handle
  18. msg - string ID for message template
  19. err - error code to substitute in
  20. psz1 - main substitution string
  21. psz2 - error code substitution string
  22. wFlags - flags to MessageBox
  23. nMsgBase - bias for error code
  24. EXIT: Returns control ID of user's choice
  25. NOTES: nMsgBase is so that the error code need not
  26. be the same as the string ID. It is added to
  27. the error code before loading the description,
  28. but the error code alone is the number inserted
  29. into the template.
  30. The text for "msg" should be of the form:
  31. The following error occurred while trying to fiddle with %1:
  32. Error %2: %3
  33. Do you want to continue fiddling?
  34. The text for "err" (+nMsgBase if appropriate) should
  35. be of the form:
  36. %1 cannot be fiddled with.
  37. In the primary message, %1 is replaced with psz1, %2
  38. is replaced with atoi(err), and %3 is replaced with
  39. a LoadString of "err". In the specific error text,
  40. %1 is replaced with psz2.
  41. HISTORY:
  42. gregj 09/30/93 Created for Chicago
  43. ********************************************************************/
  44. UINT DisplayGenericError(HWND hwnd, UINT msg, UINT err, LPCSTR psz1, LPCSTR psz2,
  45. WORD wFlags, UINT nMsgBase)
  46. {
  47. /*
  48. * setup the object name
  49. */
  50. NLS_STR nlsObjectName(STR_OWNERALLOC, (LPSTR)psz1);
  51. /*
  52. * now the error number
  53. */
  54. CHAR szErrorCode[16];
  55. wsprintf(szErrorCode,"%u",err);
  56. NLS_STR nlsErrorCode(STR_OWNERALLOC, szErrorCode);
  57. /*
  58. * fetch the error string. If cannot get, use "".
  59. */
  60. NLS_STR nlsSub1(STR_OWNERALLOC, (LPSTR)psz2);
  61. NLS_STR *apnlsParamStrings[4];
  62. apnlsParamStrings[0] = &nlsSub1;
  63. apnlsParamStrings[1] = NULL;
  64. NLS_STR nlsErrorString(NULL) ;
  65. nlsErrorString.LoadString(err + nMsgBase, (const NLS_STR **)apnlsParamStrings);
  66. err = nlsErrorString.QueryError() ;
  67. if (err)
  68. nlsErrorString = (const CHAR *)NULL;
  69. /*
  70. * then create the insert strings table
  71. */
  72. apnlsParamStrings[0] = &nlsObjectName;
  73. apnlsParamStrings[1] = &nlsErrorCode;
  74. apnlsParamStrings[2] = &nlsErrorString;
  75. apnlsParamStrings[3] = NULL;
  76. return MsgBox(hwnd, msg, wFlags, (const NLS_STR **)apnlsParamStrings);
  77. }