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.

190 lines
5.6 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: util.hxx
  7. //
  8. // Contents: Miscellaneous helper functions
  9. //
  10. // History: 4-30-1997 SusiA Created
  11. //
  12. //---------------------------------------------------------------------------
  13. #ifndef __UTIL_HXX_
  14. #define __UTIL_HXX_
  15. #include <mstask.h>
  16. #include <mobsync.h>
  17. #include "xarray.hxx"
  18. // defines for Sticking the progress dialog after sync completion
  19. #define PROGRESS_ALWAYS_CLOSE 0
  20. #define PROGRESS_STICKY_ERRORS 1
  21. #define PROGRESS_STICKY_WARNINGS 2
  22. #define PROGRESS_STICKY_INFO 4
  23. //for registry functions
  24. #define MAX_DOMANDANDMACHINENAMESIZE (DNLEN + UNLEN + 2) // character count.
  25. BOOL SetStaticString (HWND hwnd, LPTSTR pszString);
  26. VOID GetDomainAndMachineName(LPWSTR ptszDomainAndMachineName, ULONG cchBuf);
  27. BOOL RegGetCurrentUser(LPTSTR pszName, LPDWORD pdwCount);
  28. BOOL RegSetCurrentUser(LPTSTR pszName);
  29. #define MAX_KEY_LENGTH 256
  30. #define ARRAY_ELEMENT_SIZE(_a) (sizeof(_a[0]))
  31. #define ARRAY_SIZE(_a) (sizeof(_a)/sizeof(_a[0]))
  32. #define WIDTH(x) (x.right - x.left)
  33. #define HEIGHT(x) (x.bottom - x.top)
  34. // declarations for delay loading oleauto
  35. #define CodeSz(sz,val) static const TCHAR sz[] = TEXT(val)
  36. #define ProcSz(sz,val) static const char sz[] = val
  37. #define STRING_FILENAME(x,y) CodeSz(x,y)
  38. #define STRING_INTERFACE(x,y) ProcSz(x,y)
  39. //
  40. // Helpers to launch Set/Change Password & Set Account Information dialogs.
  41. //
  42. #define ZERO_PASSWORD(pswd) { \
  43. if (pswd != NULL) { \
  44. memset(pswd, 0, (lstrlenX(pswd) + 1) * sizeof(WCHAR)); \
  45. } \
  46. }
  47. void
  48. SchedUIErrorDialog(
  49. HWND hwnd,
  50. int idsErrMsg);
  51. BOOL ConvertString(LPWSTR pwszOut, char* pszIn, DWORD dwSize);
  52. BOOL ConvertString(char * pszOut, LPWSTR pwszIn, DWORD dwSize);
  53. BOOL ConvertString(LPWSTR pszOut, LPWSTR pwszIn, DWORD dwSize);
  54. BOOL ConvertMultiByteToWideChar( const char *pszIn, ULONG cbBufIn, XArray<WCHAR>& xwszBufOut, BOOL fOem = FALSE );
  55. BOOL ConvertMultiByteToWideChar( const char *pszIn, XArray<WCHAR>& xwszBufOut, BOOL fOem = FALSE );
  56. BOOL ConvertWideCharToMultiByte( const WCHAR *pwszIn, ULONG cwcBufIn, XArray<CHAR>& xszBufOut, BOOL fOem = FALSE );
  57. BOOL ConvertWideCharToMultiByte( const WCHAR *pwszIn, XArray<CHAR>& xszBufOut, BOOL fOem = FALSE );
  58. #define GUIDSTR_MAX 38
  59. #define GUID_STRING_SIZE 64
  60. HRESULT GUIDFromString(LPWSTR lpWStr, GUID * pGuid);
  61. VOID
  62. GetDefaultDomainAndUserName(
  63. LPTSTR ptszDomainAndUserName,
  64. LPTSTR ptszSeparator,
  65. ULONG cchBuf);
  66. #define UpDown_SetRange(hCtrl, min, max) (VOID)SendMessage((hCtrl), UDM_SETRANGE, 0, (LPARAM)MAKELONG((SHORT)(max), (SHORT)(min)))
  67. #define UpDown_SetPos(hCtrl, sPos) (SHORT)SendMessage((hCtrl), UDM_SETPOS, 0, (LPARAM) MAKELONG((short) sPos, 0))
  68. #define UpDown_GetPos(hCtrl) (SHORT)SendMessage((hCtrl), UDM_GETPOS, 0, 0)
  69. #define ARRAYLEN(a) (sizeof(a) / sizeof((a)[0]))
  70. void UpdateTimeFormat(LPTSTR tszTimeFormat,
  71. ULONG cchTimeFormat);
  72. //
  73. // Constants
  74. //
  75. // NDAYS_MIN - minimum value for daily_ndays_ud spin control
  76. // NDAYS_MAX - maximum value for daily_ndays_ud spin control
  77. //
  78. #define NDAYS_MIN 1
  79. #define NDAYS_MAX 365
  80. #define TASK_WEEKDAYS (TASK_MONDAY | \
  81. TASK_TUESDAY | \
  82. TASK_WEDNESDAY | \
  83. TASK_THURSDAY | \
  84. TASK_FRIDAY)
  85. VOID
  86. FillInStartDateTime(
  87. HWND hwndDatePick,
  88. HWND hwndTimePick,
  89. TASK_TRIGGER *pTrigger);
  90. // listview utilities
  91. BOOL InsertListViewColumn(CListView *pListView,int iColumndId,LPWSTR pszText,int fmt,int cx);
  92. // define blob for item listview.
  93. typedef struct _tagLVHANDLERITEMBLOB
  94. {
  95. ULONG cbSize;
  96. CLSID clsidServer;
  97. SYNCMGRITEMID ItemID;
  98. } LVHANDLERITEMBLOB;
  99. // resize utilities
  100. // resize structure, move to common when done
  101. typedef enum _tagDLGRESIZEFLAGS
  102. {
  103. DLGRESIZEFLAG_PINLEFT = 0x01,
  104. DLGRESIZEFLAG_PINTOP = 0x02,
  105. DLGRESIZEFLAG_PINRIGHT = 0x04,
  106. DLGRESIZEFLAG_PINBOTTOM = 0x08,
  107. DLGRESIZEFLAG_NOCOPYBITS = 0x10
  108. } DLGRESIZEFLAGS;
  109. typedef struct _tagDLGRESIZEINFO
  110. {
  111. int iCtrlId;
  112. HWND hwndParent;
  113. DWORD dlgResizeFlags; // taks from RESIZEFLAGS enum
  114. RECT rectParentOffsets;
  115. } DLGRESIZEINFO;
  116. BOOL InitResizeItem(int iCtrlId,DWORD dlgResizeFlags,HWND hwndParent,
  117. LPRECT pParentClientRect,DLGRESIZEINFO *pDlgResizeInfo);
  118. void ResizeItems(ULONG cbNumItems,DLGRESIZEINFO *pDlgResizeInfo);
  119. int CalcListViewWidth(HWND hwndList,int iDefault);
  120. void SetCtrlFont(HWND hwnd,DWORD dwPlatformID,LANGID langId);
  121. BOOL IsHwndRightToLeft(HWND hwnd); // determine if hwnd is right to left.
  122. DWORD GetDateFormatReadingFlags(HWND hwnd);
  123. BOOL QueryHandleException(void);
  124. BOOL SetRegKeySecurityEveryone(HKEY hKey,LPCWSTR lpSubKey);
  125. BOOL SyncMgrExecCmd_UpdateRunKey(BOOL fSet);
  126. BOOL SyncMgrExecCmd_ResetRegSecurity(void);
  127. // define locally since only available on NT 5.0 and syncmgr builds for NT 4.0 and Win9x
  128. #ifndef WS_EX_LAYOUTRTL
  129. #define WS_EX_LAYOUTRTL 0x00400000L // Right to left mirroring
  130. #endif // WS_EX_LAYOUTRTL
  131. #ifndef DATE_LTRREADING
  132. #define DATE_LTRREADING 0x00000010 // add marks for left to right reading order layout
  133. #endif // DATE_LTRREADING
  134. #ifndef DATE_RTLREADING
  135. #define DATE_RTLREADING 0x00000020 // add marks for right to left reading order layout
  136. #endif // DATE_RTLREADING
  137. #ifndef LRM
  138. #define LRM 0x200E // UNICODE Left-to-right mark control character
  139. #endif // LRM
  140. #endif // __UTIL_HXX_