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.

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