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.

362 lines
11 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltmsgp.hxx
  7. BLT Message popup header file
  8. Note: where the default button is named as "0", it means to use
  9. the same default that Windows uses.
  10. FILE HISTORY:
  11. rustanl 5-Dec-1990 Created
  12. Johnl 15-Feb-1991 Added meat
  13. RustanL 4-Mar-1991 Replaced QueryHwnd with QueryRobustHwnd
  14. beng 14-May-1991 Hack for separate compilation
  15. beng 20-Aug-1991 Const owner-window parameter
  16. chuckc 23-Sep-1991 Added DisplayGenericError
  17. beng 30-Sep-1991 Changed an amazing number of SHORTs to INTs;
  18. added MSGID business
  19. beng 17-Jun-1992 Restructuring
  20. Yi-HsinS 10-Aug-1991 Added MPSEV_QUESTION
  21. JonN 25-Aug-1992 Merged in PERFORMER::DisplayError()
  22. */
  23. #ifndef _BLT_HXX_
  24. #error "Don't include this file directly; instead, include it through blt.hxx"
  25. #endif // _BLT_HXX_
  26. #ifndef _BLTMSGP_HXX_
  27. #define _BLTMSGP_HXX_
  28. // this allows the apps that assume STRLIST as
  29. // a result of including this file to build. CODEWORK - cleanup!
  30. #include "strlst.hxx"
  31. // MsgPopup Buttons, and the shorthands of their common combinations
  32. #define MP_UNKNOWN (0x0000)
  33. #define MP_OK (0x0001)
  34. #define MP_CANCEL (0x0002)
  35. #define MP_YES (0x0004)
  36. #define MP_NO (0x0008)
  37. #define MP_OKCANCEL ( MP_OK | MP_CANCEL )
  38. #define MP_YESNO ( MP_YES | MP_NO )
  39. #define MP_YESNOCANCEL ( MP_YES | MP_NO | MP_CANCEL )
  40. // Help context options.
  41. // HC_NO_HELP means don't display a help button even if there is a help
  42. // topic for this message
  43. // HC_DEFAULT_HELP means display a help button if there is an associated
  44. // help context for this message number
  45. #define HC_NO_HELP (~0L)
  46. #define HC_DEFAULT_HELP (0L)
  47. // MsgPopup severity
  48. enum MSG_SEVERITY
  49. {
  50. MPSEV_ERROR,
  51. MPSEV_WARNING,
  52. MPSEV_INFO,
  53. MPSEV_QUESTION
  54. };
  55. // Message Map table for use by applications
  56. typedef struct _MSGMAPENTRY
  57. {
  58. MSGID msgidIn;
  59. MSGID msgidOut;
  60. } MSGMAPENTRY ;
  61. /*************************************************************************
  62. NAME: POPUP
  63. SYNOPSIS: Encapsulates messageboxes
  64. INTERFACE: POPUP() - ctor
  65. ~POPUP() - dtor
  66. Show() - displays the popup
  67. Init() - initialize module
  68. Term() - clean up before shutdown
  69. SetCaption() - Set the caption of MsgPopup
  70. ResetCaption() - Reset the caption of MsgPopup back to
  71. Windows NT
  72. SetHelpContextBase() - Set the help context base for
  73. help contexts automatically searched
  74. in the msg2help.tbl.
  75. PARENT: BASE
  76. USES: NLS_STR
  77. CAVEATS:
  78. Uses BASE only as a Boolean fError indicator.
  79. NOTES:
  80. Clients should access this class through MsgPopup() only.
  81. HISTORY:
  82. beng 17-Jun-1992 Created in restructuring
  83. beng 29-Jun-1992 Outlined Set and ResetCaption
  84. Yi-HsinS 09-Oct-1992 Added _ulHelpContextBase, SetHelpContextBase()
  85. **************************************************************************/
  86. DLL_CLASS POPUP: public BASE
  87. {
  88. private:
  89. HWND _hwndParent;
  90. MSGID _msgid;
  91. MSG_SEVERITY _msgsev;
  92. ULONG _ulHelpContext;
  93. UINT _nButtons;
  94. UINT _nDefButton;
  95. NLS_STR * _pnlsText;
  96. static BOOL _fInit;
  97. static NLS_STR * _vpnlsEmergencyText;
  98. static NLS_STR * _vpnlsEmergencyCapt;
  99. static MSGMAPENTRY * _vpmmeTable;
  100. static MSGID _vmsgidCaption;
  101. static ULONG _ulHelpContextBase;
  102. NLS_STR * LoadMessage( MSGID msgid, BOOL fTrySystem = FALSE );
  103. INT Emergency() const;
  104. static INT CalcDefButton( UINT nButtons, UINT nDefButton );
  105. static INT MapButton( UINT nButton );
  106. public:
  107. POPUP( HWND hwndOwner, MSGID msgid, MSG_SEVERITY msgsev,
  108. UINT nButtons, UINT nDefButton, BOOL fTrySystem = FALSE );
  109. POPUP( HWND hwndOwner, MSGID msgid, MSG_SEVERITY msgsev,
  110. ULONG ulHelpTopic, UINT nButtons,
  111. const NLS_STR ** apnlsInsert, UINT nDefButton );
  112. #if 0 // elide unused form
  113. POPUP( HWND hwndOwner, MSGID msgid, MSG_SEVERITY msgsev,
  114. ULONG ulHelpTopic, UINT nButtons,
  115. STRLIST & strlstInsert, UINT nDefButton );
  116. #endif
  117. ~POPUP();
  118. INT Show();
  119. static APIERR Init();
  120. static VOID Term();
  121. static VOID SetCaption( MSGID msgid );
  122. static VOID ResetCaption();
  123. static VOID SetMsgMapTable( MSGMAPENTRY * pmmeTable );
  124. static MSGID MapMessage( MSGID msgidIn );
  125. static ULONG SetHelpContextBase( ULONG ulHelpContextBase = 0 );
  126. };
  127. /*************************************************************************
  128. NAME: OWNINGWND
  129. SYNOPSIS: Hack to convert a pwnd to a robust hwnd for MsgPopup.
  130. HISTORY:
  131. beng 02-Jun-1992 Created (from PWND2HWND of bltdlg)
  132. **************************************************************************/
  133. DLL_CLASS OWNINGWND
  134. {
  135. private:
  136. HWND _hwnd;
  137. public:
  138. OWNINGWND( HWND hwnd ) : _hwnd(hwnd) { }
  139. OWNINGWND( const OWNER_WINDOW * pwnd )
  140. : _hwnd(pwnd->QueryRobustHwnd()) { }
  141. HWND QueryHwnd() const
  142. { return _hwnd; }
  143. };
  144. /*
  145. * Call this function during application initialization to properly
  146. * initialize the message popup stuff (only affects msgpopup during
  147. * low memory/resource failure situations).
  148. *
  149. * These are called automatically when BLTRegister is called (an app.
  150. * shouldn't call these directly).
  151. *
  152. * UnInitMsgPopup should be called during application shutdown. It frees
  153. * resources allocated by InitMsgPopup.
  154. */
  155. inline APIERR InitMsgPopup()
  156. {
  157. return POPUP::Init();
  158. }
  159. inline VOID UnInitMsgPopup()
  160. {
  161. POPUP::Term();
  162. }
  163. //
  164. // The MsgPopup function declarations
  165. //
  166. // The following form takes the help context from the resource
  167. // file, and uses an OK button.
  168. extern DLL_BASED
  169. INT MsgPopup( const OWNINGWND & wnd,
  170. MSGID msgid,
  171. MSG_SEVERITY msgsev = MPSEV_ERROR );
  172. // The following form allows the client to specify a set of buttons,
  173. // as well as an optional default button. The help context is taken from
  174. // the resource file.
  175. extern DLL_BASED
  176. INT MsgPopup( const OWNINGWND & wnd,
  177. MSGID msgid,
  178. MSG_SEVERITY msgsev,
  179. UINT nButtons,
  180. UINT nDefButton = MP_UNKNOWN );
  181. // The following form allows the client to specify insert strings, as
  182. // well as a choice of buttons. Help context is taken from the resource
  183. // file. The insert strings come in three flavors, a single parameter,
  184. // two parameters and > two parameters. This is for ease of use since
  185. // 95% of the message strings take one or two parameters.
  186. extern DLL_BASED
  187. INT MsgPopup( const OWNINGWND & wnd,
  188. MSGID msgid,
  189. MSG_SEVERITY msgsev,
  190. UINT nButtons,
  191. const TCHAR * pszIns,
  192. UINT nDefButton = MP_UNKNOWN );
  193. extern DLL_BASED
  194. INT MsgPopup( const OWNINGWND & wnd,
  195. MSGID msgid,
  196. MSG_SEVERITY msgsev,
  197. UINT nButtons,
  198. const TCHAR * pszIns1,
  199. const TCHAR * pszIns2,
  200. UINT nDefButton = MP_UNKNOWN );
  201. /*
  202. One further refinement: This form allows the user to
  203. specify both a MSGID and an APIERR. The string for this
  204. APIERR will be inserted into the MSGID string as %1,
  205. while the apnlsInserted strings will be shifted to %2
  206. and higher. If the APIERR string cannot be found,
  207. a string containing the error number and class will be
  208. inserted instead.
  209. */
  210. extern DLL_BASED
  211. INT MsgPopup( const OWNINGWND & wnd,
  212. MSGID msgid,
  213. APIERR errAPI,
  214. MSG_SEVERITY msgsev,
  215. ULONG ulHelpTopic,
  216. UINT nButtons,
  217. NLS_STR * apnlsParams[],
  218. UINT nDefButton = MP_UNKNOWN );
  219. #if 0 // strlist form never used
  220. INT MsgPopup( const OWNINGWND & wnd,
  221. MSGID msgid,
  222. MSG_SEVERITY msgsev,
  223. UINT nButtons,
  224. STRLIST & strlst,
  225. UINT nDefButton = MP_UNKNOWN );
  226. #endif
  227. // Finally, these forms allow the client to have it all. They take
  228. // as parameters insert strings (note, that an insert string object may
  229. // contain 0 insert strings, if desired), a help topic, and a choice of
  230. // buttons.
  231. #if 0 // strlist form never used
  232. INT MsgPopup( const OWNINGWND & wnd,
  233. MSGID msgid,
  234. MSG_SEVERITY msgsev,
  235. ULONG ulHelpTopic,
  236. UINT nButtons,
  237. STRLIST & strlst,
  238. UINT nDefButton = MP_UNKNOWN );
  239. #endif
  240. extern DLL_BASED
  241. INT MsgPopup( const OWNINGWND & wnd,
  242. MSGID msgid,
  243. MSG_SEVERITY msgsev,
  244. ULONG ulHelpTopic,
  245. UINT nButtons,
  246. NLS_STR * apnlsInserted[],
  247. UINT nDefButton = MP_UNKNOWN );
  248. /*
  249. This function is used to display a generic error message of form:
  250. Some error on object %objectname%.
  251. Error %apierr% occurred: %text_for_api_err%
  252. idMessage should refer to a resource string of the form above, eg:
  253. The world collapsed while stopping server %1.
  254. Error %2 occurred: %3%.
  255. pszObjectName will be substituted in %1, errAPI in %2, and the
  256. corresponding API text in %3. If we cannot find the text for the
  257. API err, we just leave the text out. errAPI is expected to be in
  258. the SYS/NET range.
  259. */
  260. extern DLL_BASED
  261. UINT DisplayGenericError( const OWNINGWND & wnd,
  262. MSGID msgid,
  263. APIERR errAPI,
  264. const TCHAR * pszObject1,
  265. const TCHAR * pszObject2,
  266. MSG_SEVERITY msgsev = MPSEV_ERROR );
  267. extern DLL_BASED
  268. UINT DisplayGenericError( const OWNINGWND & wnd,
  269. MSGID msgid,
  270. APIERR errAPI,
  271. const TCHAR * pszObjectName,
  272. MSG_SEVERITY msgsev = MPSEV_ERROR );
  273. #endif // _BLTMSGP_HXX_ - end of file