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.

183 lines
3.4 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. #ifdef _INC_SHELLAPI
  90. HRESULT
  91. HrShell_NotifyIcon (
  92. DWORD dwMessage,
  93. PNOTIFYICONDATA pData);
  94. #endif // _INC_SHELLAPI
  95. NOTHROW
  96. LRESULT
  97. LresFromHr (
  98. HRESULT hr);
  99. NOTHROW
  100. INT
  101. WINAPIV
  102. NcMsgBox (
  103. HINSTANCE hinst,
  104. HWND hwnd,
  105. UINT unIdCaption,
  106. UINT unIdFormat,
  107. UINT unStyle,
  108. ...);
  109. NOTHROW
  110. INT
  111. WINAPIV
  112. NcMsgBoxWithVarCaption (
  113. HINSTANCE hinst,
  114. HWND hwnd,
  115. UINT unIdCaption,
  116. PCWSTR szCaptionParam,
  117. UINT unIdFormat,
  118. UINT unStyle,
  119. ...);
  120. NOTHROW
  121. INT
  122. WINAPIV
  123. NcMsgBoxWithWin32ErrorText (
  124. DWORD dwError,
  125. HINSTANCE hinst,
  126. HWND hwnd,
  127. UINT unIdCaption,
  128. UINT unIdCombineFormat,
  129. UINT unIdFormat,
  130. UINT unStyle,
  131. ...);
  132. VOID
  133. SendDlgItemsMessage (
  134. HWND hDlg,
  135. INT ccid,
  136. const INT* acid,
  137. UINT unMsg,
  138. WPARAM wParam,
  139. LPARAM lParam);
  140. VOID
  141. SetDefaultButton(
  142. HWND hdlg,
  143. INT iddef);
  144. struct CONTEXTIDMAP
  145. {
  146. INT idControl;
  147. DWORD dwContextId;
  148. DWORD dwContextIdJapan;
  149. };
  150. typedef const CONTEXTIDMAP * PCCONTEXTIDMAP;
  151. VOID OnHelpGeneric(
  152. HWND hwnd,
  153. LPHELPINFO lphi,
  154. PCCONTEXTIDMAP pContextMap,
  155. BOOL bJpn,
  156. PCWSTR pszHelpFile);
  157. #endif // _NCUI_H_