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.

240 lines
4.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C U I . H
  7. //
  8. // Contents: Common user interface routines.
  9. //
  10. // Notes:
  11. //
  12. // Author: shaunco 24 Mar 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NCUI_H_
  17. #define _NCUI_H_
  18. #include "ncbase.h"
  19. inline
  20. HCURSOR
  21. BeginWaitCursor ()
  22. {
  23. return SetCursor(LoadCursor(NULL, IDC_WAIT));
  24. }
  25. inline
  26. VOID
  27. EndWaitCursor (
  28. HCURSOR hcurPrev)
  29. {
  30. // BeginWaitCursor may return a NULL cursor. This is just
  31. // a saftey net.
  32. //
  33. if (!hcurPrev)
  34. {
  35. hcurPrev = LoadCursor(NULL, IDC_ARROW);
  36. }
  37. SetCursor(hcurPrev);
  38. }
  39. // To get an automatic wait cursor, simply declare an instance
  40. // of CWaitCursor. The cursor will be restored when the instance is
  41. // destroyed. (i.e. declare it on the stack.)
  42. //
  43. class CWaitCursor
  44. {
  45. private:
  46. HCURSOR m_hcurPrev;
  47. public:
  48. CWaitCursor () { m_hcurPrev = BeginWaitCursor (); }
  49. ~CWaitCursor () { EndWaitCursor (m_hcurPrev); }
  50. };
  51. //
  52. // Enables or disables a set of controls in a dialog.
  53. //
  54. // Use this when you're enabling/disabling more than about two controls.
  55. // Be sure to declare the array of control ids as 'static const' if you can.
  56. //
  57. NOTHROW
  58. VOID
  59. EnableOrDisableDialogControls (
  60. HWND hDlg,
  61. INT ccid,
  62. const INT* acid,
  63. BOOL fEnable);
  64. //
  65. // Map back and forth between a set of radio buttons and a DWORD value.
  66. //
  67. // Be sure to declare the array as 'static const' if you can.
  68. //
  69. struct RADIO_BUTTON_MAP
  70. {
  71. INT cid; // control id of radio button
  72. DWORD dwValue; // value associated with this radio button
  73. };
  74. NOTHROW
  75. BOOL
  76. FMapRadioButtonToValue (
  77. HWND hDlg,
  78. INT crbm,
  79. const RADIO_BUTTON_MAP* arbm,
  80. DWORD* pdwValue);
  81. NOTHROW
  82. BOOL
  83. FMapValueToRadioButton (
  84. HWND hDlg,
  85. INT crbm,
  86. const RADIO_BUTTON_MAP* arbm,
  87. DWORD dwValue,
  88. INT* pncid);
  89. INT
  90. GetIntegerFormat (
  91. LCID Locale,
  92. PCWSTR pszValue,
  93. PWSTR pszFormattedValue,
  94. INT cchFormattedValue);
  95. INT
  96. Format32bitInteger (
  97. UINT32 unValue,
  98. BOOL fSigned,
  99. PWSTR pszFormattedValue,
  100. INT cchFormattedValue);
  101. INT
  102. Format64bitInteger (
  103. UINT64 ulValue,
  104. BOOL fSigned,
  105. PWSTR pszFormattedValue,
  106. INT cchFormattedValue);
  107. BOOL
  108. SetDlgItemFormatted32bitInteger (
  109. HWND hDlg,
  110. INT nIdDlgItem,
  111. UINT32 unValue,
  112. BOOL fSigned);
  113. BOOL
  114. SetDlgItemFormatted64bitInteger (
  115. HWND hDlg,
  116. INT nIdDlgItem,
  117. UINT64 ulValue,
  118. BOOL fSigned);
  119. // dwFlags for HrNcQueryUserForRebootEx
  120. //
  121. // Combine both to get original behavior, or do one at a time to first prompt
  122. // then second, actually reboot.
  123. //
  124. //#define QUFR_PROMPT 0x00000001
  125. //#define QUFR_REBOOT 0x00000002
  126. HRESULT
  127. HrNcQueryUserForRebootEx (
  128. HWND hwndParent,
  129. PCWSTR pszCaption,
  130. PCWSTR pszText,
  131. DWORD dwFlags);
  132. HRESULT
  133. HrNcQueryUserForReboot (
  134. HINSTANCE hinst,
  135. HWND hwndParent,
  136. UINT unIdCaption,
  137. UINT unIdText,
  138. DWORD dwFlags);
  139. #ifdef _INC_SHELLAPI
  140. HRESULT
  141. HrShell_NotifyIcon (
  142. DWORD dwMessage,
  143. PNOTIFYICONDATA pData);
  144. #endif // _INC_SHELLAPI
  145. NOTHROW
  146. LRESULT
  147. LresFromHr (
  148. HRESULT hr);
  149. NOTHROW
  150. INT
  151. WINAPIV
  152. NcMsgBox (
  153. HINSTANCE hinst,
  154. HWND hwnd,
  155. UINT unIdCaption,
  156. UINT unIdFormat,
  157. UINT unStyle,
  158. ...);
  159. NOTHROW
  160. INT
  161. WINAPIV
  162. NcMsgBoxWithVarCaption (
  163. HINSTANCE hinst,
  164. HWND hwnd,
  165. UINT unIdCaption,
  166. PCWSTR szCaptionParam,
  167. UINT unIdFormat,
  168. UINT unStyle,
  169. ...);
  170. NOTHROW
  171. INT
  172. WINAPIV
  173. NcMsgBoxWithWin32ErrorText (
  174. DWORD dwError,
  175. HINSTANCE hinst,
  176. HWND hwnd,
  177. UINT unIdCaption,
  178. UINT unIdCombineFormat,
  179. UINT unIdFormat,
  180. UINT unStyle,
  181. ...);
  182. VOID
  183. SendDlgItemsMessage (
  184. HWND hDlg,
  185. INT ccid,
  186. const INT* acid,
  187. UINT unMsg,
  188. WPARAM wParam,
  189. LPARAM lParam);
  190. VOID
  191. SetDefaultButton(
  192. HWND hdlg,
  193. INT iddef);
  194. struct CONTEXTIDMAP
  195. {
  196. INT idControl;
  197. DWORD dwContextId;
  198. DWORD dwContextIdJapan;
  199. };
  200. typedef const CONTEXTIDMAP * PCCONTEXTIDMAP;
  201. VOID OnHelpGeneric(
  202. HWND hwnd,
  203. LPHELPINFO lphi,
  204. PCCONTEXTIDMAP pContextMap,
  205. BOOL bJpn,
  206. PCWSTR pszHelpFile);
  207. #endif // _NCUI_H_