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.

222 lines
6.7 KiB

  1. #ifndef _SAUTIL_H
  2. #define _SAUTIL_H
  3. #include "resource.h"
  4. #define TRACE(a)
  5. #define TRACE1(a,b)
  6. #define TRACE2(a,b,c)
  7. #define TRACE3(a,b,c,d)
  8. extern HINSTANCE g_hinstDll; // in saui.cpp
  9. /* Heap allocation macros allowing easy substitution of alternate heap. These
  10. ** are used by the other utility sections.
  11. */
  12. #ifndef EXCL_HEAPDEFS
  13. #define Malloc(c) (void*)GlobalAlloc(0,(c))
  14. #define Realloc(p,c) (void*)GlobalReAlloc((p),(c),GMEM_MOVEABLE)
  15. #define Free(p) (void*)GlobalFree(p)
  16. #endif
  17. VOID ContextHelp(
  18. IN const DWORD* padwMap,
  19. IN HWND hwndDlg,
  20. IN UINT unMsg,
  21. IN WPARAM wparam,
  22. IN LPARAM lparam);
  23. VOID AddContextHelpButton (IN HWND hwnd);
  24. /* Extended arguments for the MsgDlgUtil routine. Designed so zeroed gives
  25. ** default behaviors.
  26. */
  27. #define MSGARGS struct tagMSGARGS
  28. MSGARGS
  29. {
  30. /* Insertion strings for arguments %1 to %9 in the 'dwMsg' string, or
  31. ** NULLs if none.
  32. */
  33. TCHAR* apszArgs[ 9 ];
  34. /* Currently, as for MessageBox, where defaults if 0 are MB_OK and
  35. ** MB_ICONINFORMATION.
  36. */
  37. DWORD dwFlags;
  38. /* If non-NULL, specifies a string overriding the loading of the 'dwMsg'
  39. ** parameter string.
  40. */
  41. TCHAR* pszString;
  42. /* If 'fStringOutput' is true, the MsgDlgUtil returns the formatted text
  43. ** string that would otherwise be displayed in the popup in 'pszOutput'.
  44. ** It is caller's responsibility to LocalFree the returned string.
  45. */
  46. BOOL fStringOutput;
  47. TCHAR* pszOutput;
  48. };
  49. int
  50. MsgDlgUtil(
  51. IN HWND hwndOwner,
  52. IN DWORD dwMsg,
  53. IN OUT MSGARGS* pargs,
  54. IN HINSTANCE hInstance,
  55. IN DWORD dwTitle );
  56. VOID UnclipWindow (IN HWND hwnd);
  57. VOID CenterWindow (IN HWND hwnd, IN HWND hwndRef);
  58. LRESULT CALLBACK CenterDlgOnOwnerCallWndProc (int code, WPARAM wparam, LPARAM lparam);
  59. TCHAR* PszFromId (IN HINSTANCE hInstance, IN DWORD dwStringId);
  60. TCHAR* GetText (IN HWND hwnd);
  61. BOOL GetErrorText (DWORD dwError, TCHAR** ppszError);
  62. #define ERRORARGS struct tagERRORARGS
  63. ERRORARGS
  64. {
  65. /* Insertion strings for arguments %1 to %9 in the 'dwOperation' string,
  66. ** or NULLs if none.
  67. */
  68. TCHAR* apszOpArgs[ 9 ];
  69. /* Insertion strings for auxillary arguments %4 to %6 in the 'dwFormat'
  70. ** string, or NULLs if none. (The standard arguments are %1=the
  71. ** 'dwOperation' string, %2=the decimal error number, and %3=the
  72. ** 'dwError'string.)
  73. */
  74. TCHAR* apszAuxFmtArgs[ 3 ];
  75. /* If 'fStringOutput' is true, the ErrorDlgUtil returns the formatted text
  76. ** string that would otherwise be displayed in the popup in 'pszOutput'.
  77. ** It is caller's responsibility to LocalFree the returned string.
  78. */
  79. BOOL fStringOutput;
  80. TCHAR* pszOutput;
  81. };
  82. int
  83. ErrorDlgUtil(
  84. IN HWND hwndOwner,
  85. IN DWORD dwOperation,
  86. IN DWORD dwError,
  87. IN OUT ERRORARGS* pargs,
  88. IN HINSTANCE hInstance,
  89. IN DWORD dwTitle,
  90. IN DWORD dwFormat );
  91. int MsgDlgUtil(IN HWND hwndOwner, IN DWORD dwMsg, IN OUT MSGARGS* pargs, IN HINSTANCE hInstance, IN DWORD dwTitle);
  92. #define MsgDlg(h,m,a) \
  93. MsgDlgUtil(h,m,a,g_hinstDll,SID_PopupTitle)
  94. #define ErrorDlg(h,o,e,a) \
  95. ErrorDlgUtil(h,o,e,a,g_hinstDll,SID_PopupTitle,SID_FMT_ErrorMsg)
  96. // LVX stuff (cut-n-paste'd from ...\net\rras\ras\ui\common\uiutil\lvx.c, etc.
  97. /* Text indents within a column in pixels. If you mess with the dx, you're
  98. ** asking for misalignment problems with the header labels. BTW, the first
  99. ** column doesn't line up with it's header if there are no icons. Regular
  100. ** list view has this problem, too. If you try to fix this you'll wind up
  101. ** duplicating the AUTOSIZE_USEHEADER option of ListView_SetColumnWidth.
  102. ** Should be able to change the dy without causing problems.
  103. */
  104. #define LVX_dxColText 4
  105. #define LVX_dyColText 1
  106. /* Guaranteed vertical space between icons. Should be able to mess with this
  107. ** without causing problems.
  108. */
  109. #define LVX_dyIconSpacing 1
  110. #define SI_Unchecked 1
  111. #define SI_Checked 2
  112. #define SI_DisabledUnchecked 3
  113. #define SI_DisabledChecked 4
  114. #define LVXN_SETCHECK (LVN_LAST + 1)
  115. #define LVXN_DBLCLK (LVN_LAST + 2)
  116. /* The extended list view control calls the owner back to find out the layout
  117. ** and desired characteristics of the enhanced list view.
  118. */
  119. #define LVX_MaxCols 10
  120. #define LVX_MaxColTchars 512
  121. /* 'dwFlags' option bits.
  122. */
  123. #define LVXDI_DxFill 1 // Auto-fill wasted space on right (recommended)
  124. #define LVXDI_Blend50Sel 2 // Dither small icon if selected (not recommended)
  125. #define LVXDI_Blend50Dis 4 // Dither small icon if disabled (recommended)
  126. /* 'adwFlags' option bits.
  127. */
  128. #define LVXDIA_3dFace 1 // Column is not editable but other columns are
  129. #define LVXDIA_Static 2 // Emulates static text control w/icon if disabled
  130. /* Returned by owner at draw item time.
  131. */
  132. #define LVXDRAWINFO struct tagLVXDRAWINFO
  133. LVXDRAWINFO
  134. {
  135. /* The number of columns. The list view extensions require that your
  136. ** columns are numbered sequentially from left to right where 0 is the
  137. ** item column and 1 is the first sub-item column. Required always.
  138. */
  139. INT cCols;
  140. /* Pixels to indent this item, or -1 to indent a "small icon" width. Set
  141. ** 0 to disable.
  142. */
  143. INT dxIndent;
  144. /* LVXDI_* options applying to all columns.
  145. */
  146. DWORD dwFlags;
  147. /* LVXDIA_* options applying to individual columns.
  148. */
  149. DWORD adwFlags[ LVX_MaxCols ];
  150. };
  151. typedef LVXDRAWINFO* (*PLVXCALLBACK)( IN HWND, IN DWORD dwItem );
  152. BOOL ListView_IsCheckDisabled (IN HWND hwndLv, IN INT iItem);
  153. VOID ListView_SetCheck (IN HWND hwndLv, IN INT iItem, IN BOOL fCheck);
  154. VOID* ListView_GetParamPtr(IN HWND hwndLv, IN INT iItem);
  155. BOOL ListView_GetCheck(IN HWND hwndLv, IN INT iItem);
  156. LRESULT APIENTRY LvxcbProc(
  157. IN HWND hwnd,
  158. IN UINT unMsg,
  159. IN WPARAM wparam,
  160. IN LPARAM lparam );
  161. BOOL ListView_InstallChecks(IN HWND hwndLv, IN HINSTANCE hinst);
  162. VOID ListView_InsertSingleAutoWidthColumn (HWND hwndLv);
  163. TCHAR* Ellipsisize(
  164. IN HDC hdc,
  165. IN TCHAR* psz,
  166. IN INT dxColumn,
  167. IN INT dxColText OPTIONAL);
  168. BOOL LvxDrawItem(IN DRAWITEMSTRUCT* pdis, IN PLVXCALLBACK pLvxCallback);
  169. BOOL LvxMeasureItem(IN HWND hwnd, IN OUT MEASUREITEMSTRUCT* pmis);
  170. BOOL ListView_OwnerHandler(
  171. IN HWND hwnd,
  172. IN UINT unMsg,
  173. IN WPARAM wparam,
  174. IN LPARAM lparam,
  175. IN PLVXCALLBACK pLvxCallback );
  176. TCHAR* _StrDup(LPCTSTR psz);
  177. TCHAR* StrDupTFromW (LPCWSTR psz);
  178. WCHAR* StrDupWFromT (LPCTSTR psz);
  179. void IpHostAddrToPsz(IN DWORD dwAddr, OUT LPTSTR pszBuffer);
  180. DWORD IpPszToHostAddr(IN LPCTSTR cp);
  181. VOID* Free0 (VOID* p);
  182. HRESULT ActivateLuna(HANDLE* phActivationContext, ULONG_PTR* pulCookie);
  183. HRESULT DeactivateLuna(HANDLE hActivationContext, ULONG_PTR ulCookie);
  184. #endif