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.

279 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. dtp.h
  5. Abstract:
  6. DateTimePicker common control MFC wrapper definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _DTP_H
  14. #define _DTP_H
  15. //
  16. // Notification Handler Macros
  17. //
  18. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  19. #define ON_DATETIMECHANGE(id, memberFxn)\
  20. ON_NOTIFY(DTN_DATETIMECHANGE, id, memberFxn)
  21. #define ON_USERSTRING(id, memberFxn)\
  22. ON_NOTIFY(DTN_USERSTRING, id, memberFxn)
  23. class COMDLL CDateTimePicker : public CWnd
  24. /*--
  25. Class Description:
  26. DateTimePicker MFC control wrapper.
  27. Public Interface:
  28. CDateTimePicker : Constructor
  29. ~CDateTimePicker : Destructor
  30. Create : Create the control
  31. GetSystemTime : Get systemtime struct value from control
  32. SetSystemTime : Set control time value from systemtime struct
  33. GetRange : Get the min/max time range
  34. SetRange : Set the min/max time range
  35. SetFormat : Set display formatting string
  36. GetMonthCalColor : Get the month calendar colour
  37. SetMonthCalColor : Set the month calendar colour
  38. Notes:
  39. Either create control dynamically with Create method, or put in resource
  40. template as a user control of name "SysDateTimePick32". In this case,
  41. common style DWORDs as follows:
  42. WS_BORDER | WS_CHILD | WS_VISIBLE 0x50800000
  43. DTS_UPDOWN 0x0001
  44. DTS_SHOWNONE 0x0002
  45. DTS_SHORTDATEFORMAT 0x0000
  46. DTS_LONGDATEFORMAT 0x0004
  47. DTS_TIMEFORMAT 0x0009
  48. DTS_APPCANPARSE 0x0010
  49. DTS_RIGHTALIGN 0x0020
  50. Time and date format changes are automatically picked up by the control
  51. --*/
  52. {
  53. DECLARE_DYNAMIC(CDateTimePicker)
  54. //
  55. // Constructor/Destructor
  56. //
  57. public:
  58. CDateTimePicker();
  59. ~CDateTimePicker();
  60. //
  61. // Interface
  62. //
  63. public:
  64. //
  65. // Create the control
  66. //
  67. BOOL Create(
  68. IN LPCTSTR lpszName,
  69. IN DWORD dwStyle,
  70. IN const RECT & rect,
  71. IN CWnd * pParentWnd,
  72. IN UINT nID
  73. );
  74. //
  75. // Returns GDT_NONE if "none" is selected (DTS_SHOWNONE only)
  76. // Returns GDT_VALID and modifies *pst to be the currently selected value
  77. //
  78. DWORD GetSystemTime(
  79. OUT LPSYSTEMTIME pst
  80. );
  81. //
  82. // Sets datetimepick to None (DTS_SHOWNONE only)
  83. // Returns TRUE on success, FALSE on error (such as bad params)
  84. //
  85. BOOL SetSystemTime();
  86. //
  87. // Sets datetimepick to *pst
  88. // Returns TRUE on success, FALSE on error (such as bad params)
  89. //
  90. BOOL SetSystemTime(
  91. IN LPSYSTEMTIME pst
  92. );
  93. //
  94. // Modifies rgst[0] to be the minimum ALLOWABLE systemtime (or 0 if no min)
  95. // Modifies rgst[1] to be the maximum ALLOWABLE systemtime (or 0 if no max)
  96. // Returns GDTR_MIN | GDTR_MAX if there is a minimum | maximum limit
  97. //
  98. DWORD GetRange(
  99. OUT LPSYSTEMTIME rgst
  100. );
  101. //
  102. // If GDTR_MIN, sets the minimum ALLOWABLE systemtime to rgst[0],
  103. // otherwise removes minimum
  104. //
  105. // If GDTR_MAX, sets the maximum ALLOWABLE systemtime to rgst[1],
  106. // otherwise removes maximum
  107. //
  108. // Returns TRUE on success, FALSE on error (such as invalid parameters)
  109. //
  110. BOOL SetRange(
  111. IN DWORD gdtr,
  112. IN LPSYSTEMTIME rgst
  113. );
  114. //
  115. // Sets the display formatting string to sz (see GetDateFormat and
  116. // GetTimeFormat for valid formatting chars)
  117. //
  118. // NOTE: 'X' is a valid formatting character which indicates that
  119. // the application will determine how to display information.
  120. // Such apps must support DTN_WMKEYDOWN, DTN_FORMAT,
  121. // and DTN_FORMATQUERY.
  122. //
  123. BOOL SetFormat(
  124. IN LPCTSTR sz
  125. );
  126. //
  127. // Sets the month calendar colour
  128. //
  129. BOOL SetMonthCalColor(
  130. IN int iColor,
  131. IN COLORREF clr
  132. );
  133. //
  134. // Returns the month calendar colour
  135. //
  136. COLORREF GetMonthCalColor(
  137. IN int iColor
  138. );
  139. protected:
  140. //
  141. // Register the control if not yet registered.
  142. //
  143. static BOOL RegisterClass();
  144. private:
  145. static BOOL m_fClassRegistered;
  146. };
  147. //
  148. // Inline Expansion
  149. //
  150. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  151. inline BOOL CDateTimePicker::Create(
  152. IN LPCTSTR lpszName,
  153. IN DWORD dwStyle,
  154. IN const RECT & rect,
  155. IN CWnd * pParentWnd,
  156. IN UINT nID
  157. )
  158. {
  159. //
  160. // Create the control
  161. //
  162. return CWnd::Create(
  163. DATETIMEPICK_CLASS,
  164. lpszName,
  165. dwStyle,
  166. rect,
  167. pParentWnd,
  168. nID
  169. );
  170. }
  171. inline DWORD CDateTimePicker::GetSystemTime(
  172. OUT LPSYSTEMTIME pst
  173. )
  174. {
  175. return DateTime_GetSystemtime(m_hWnd, pst);
  176. }
  177. inline BOOL CDateTimePicker::SetSystemTime()
  178. {
  179. return DateTime_SetSystemtime(m_hWnd, GDT_NONE, NULL);
  180. }
  181. inline BOOL CDateTimePicker::SetSystemTime(
  182. IN LPSYSTEMTIME pst
  183. )
  184. {
  185. ASSERT(pst != NULL);
  186. return DateTime_SetSystemtime(m_hWnd, GDT_VALID, pst);
  187. }
  188. inline DWORD CDateTimePicker::GetRange(
  189. OUT LPSYSTEMTIME rgst
  190. )
  191. {
  192. ASSERT(rgst != NULL);
  193. return DateTime_GetRange(m_hWnd, rgst);
  194. }
  195. inline BOOL CDateTimePicker::SetRange(
  196. IN DWORD gdtr,
  197. IN LPSYSTEMTIME rgst
  198. )
  199. {
  200. ASSERT(rgst != NULL);
  201. ASSERT(gdtr & (GDTR_MIN | GDTR_MAX));
  202. return DateTime_SetRange(m_hWnd, gdtr, rgst);
  203. }
  204. inline BOOL CDateTimePicker::SetFormat(
  205. IN LPCTSTR sz
  206. )
  207. {
  208. ASSERT(sz != NULL);
  209. return DateTime_SetFormat(m_hWnd, sz);
  210. }
  211. inline BOOL CDateTimePicker::SetMonthCalColor(
  212. IN int iColor,
  213. IN COLORREF clr
  214. )
  215. {
  216. return (BOOL)DateTime_SetMonthCalColor(m_hWnd, iColor, clr);
  217. }
  218. inline COLORREF CDateTimePicker::GetMonthCalColor(
  219. IN int iColor
  220. )
  221. {
  222. return (COLORREF)DateTime_GetMonthCalColor(m_hWnd, iColor);
  223. }
  224. #endif // _DTP_H