XTPCalendarCustomDataProvider.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:5k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarCustomDataProvider.cpp: implementation of the
  2. // CXTPCalendarCustomProperties class.
  3. //
  4. // This file is a part of the XTREME CALENDAR MFC class library.
  5. // (c)1998-2008 Codejock Software, All Rights Reserved.
  6. //
  7. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  8. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  9. // CONSENT OF CODEJOCK SOFTWARE.
  10. //
  11. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  12. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  13. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  14. // SINGLE COMPUTER.
  15. //
  16. // CONTACT INFORMATION:
  17. // support@codejock.com
  18. // http://www.codejock.com
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #include "stdafx.h"
  22. #include "XTPCalendarCustomDataProvider.h"
  23. #include "XTPCalendarNotifications.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. IMPLEMENT_DYNAMIC(CXTPCalendarCustomDataProvider, CXTPCalendarData)
  30. CXTPCalendarCustomDataProvider::CXTPCalendarCustomDataProvider()
  31. {
  32. m_typeProvider = xtpCalendarDataProviderCustom;
  33. SetCacheMode(xtpCalendarDPCacheModeOnRepeat);
  34. }
  35. CXTPCalendarCustomDataProvider::~CXTPCalendarCustomDataProvider()
  36. {
  37. }
  38. void CXTPCalendarCustomDataProvider::Close()
  39. {
  40. if (!IsOpen())
  41. {
  42. CXTPCalendarData::Open();
  43. }
  44. CXTPCalendarData::Close();
  45. }
  46. CXTPCalendarEventsPtr CXTPCalendarCustomDataProvider::DoRetrieveDayEvents(COleDateTime dtDay)
  47. {
  48. CXTPCalendarEventsPtr ptrEvents;
  49. WPARAM wParam = (XTP_DATE_VALUE)(double)dtDay;
  50. LPARAM lParam = (LPARAM)&ptrEvents;
  51. SendNotification(XTP_NC_CALENDAR_DoRetrieveDayEvents, wParam, lParam);
  52. return ptrEvents;
  53. }
  54. void CXTPCalendarCustomDataProvider::DoRemoveAllEvents()
  55. {
  56. SendNotification(XTP_NC_CALENDAR_DoRemoveAllEvents, 0, 0);
  57. }
  58. CXTPCalendarEventPtr CXTPCalendarCustomDataProvider::DoRead_Event(DWORD dwEventID)
  59. {
  60. CXTPCalendarEventPtr ptrEvent;
  61. WPARAM wParam = (WPARAM)dwEventID;
  62. LPARAM lParam = (LPARAM)&ptrEvent;
  63. SendNotification(XTP_NC_CALENDAR_DoRead_Event, wParam, lParam);
  64. return ptrEvent;
  65. }
  66. CXTPCalendarRecurrencePatternPtr CXTPCalendarCustomDataProvider::DoRead_RPattern(DWORD dwPatternID)
  67. {
  68. CXTPCalendarRecurrencePatternPtr ptrPattern;
  69. WPARAM wParam = (WPARAM)dwPatternID;
  70. LPARAM lParam = (LPARAM)&ptrPattern;
  71. SendNotification(XTP_NC_CALENDAR_DoRead_RPattern, wParam, lParam);
  72. return ptrPattern;
  73. }
  74. BOOL CXTPCalendarCustomDataProvider::DoCreate_Event(CXTPCalendarEvent* pEvent, DWORD& rdwNewEventID)
  75. {
  76. BOOL bResult = -1;
  77. XTP_CALENDAR_WPARAM2 wParamX2;
  78. wParamX2.wParam1 = (WPARAM)pEvent;
  79. wParamX2.wParam2 = (WPARAM)&rdwNewEventID;
  80. WPARAM wParam = (WPARAM)&wParamX2;
  81. LPARAM lParam = (LPARAM)&bResult;
  82. SendNotification(XTP_NC_CALENDAR_DoCreate_Event, wParam, lParam);
  83. return bResult > 0;
  84. }
  85. BOOL CXTPCalendarCustomDataProvider::DoUpdate_Event (CXTPCalendarEvent* pEvent)
  86. {
  87. BOOL bResult = -1;
  88. WPARAM wParam = (WPARAM)pEvent;
  89. LPARAM lParam = (LPARAM)&bResult;
  90. SendNotification(XTP_NC_CALENDAR_DoUpdate_Event, wParam, lParam);
  91. return bResult > 0;
  92. }
  93. BOOL CXTPCalendarCustomDataProvider::DoDelete_Event (CXTPCalendarEvent* pEvent)
  94. {
  95. BOOL bResult = -1;
  96. WPARAM wParam = (WPARAM)pEvent;
  97. LPARAM lParam = (LPARAM)&bResult;
  98. SendNotification(XTP_NC_CALENDAR_DoDelete_Event, wParam, lParam);
  99. return bResult > 0;
  100. }
  101. BOOL CXTPCalendarCustomDataProvider::DoCreate_RPattern(CXTPCalendarRecurrencePattern* pPattern, DWORD& rdwNewPatternID)
  102. {
  103. BOOL bResult = -1;
  104. XTP_CALENDAR_WPARAM2 wParamX2;
  105. wParamX2.wParam1 = (WPARAM)pPattern;
  106. wParamX2.wParam2 = (WPARAM)&rdwNewPatternID;
  107. WPARAM wParam = (WPARAM)&wParamX2;
  108. LPARAM lParam = (LPARAM)&bResult;
  109. SendNotification(XTP_NC_CALENDAR_DoCreate_RPattern, wParam, lParam);
  110. return bResult > 0;
  111. }
  112. BOOL CXTPCalendarCustomDataProvider::DoUpdate_RPattern(CXTPCalendarRecurrencePattern* pPattern)
  113. {
  114. BOOL bResult = -1;
  115. WPARAM wParam = (WPARAM)pPattern;
  116. LPARAM lParam = (LPARAM)&bResult;
  117. SendNotification(XTP_NC_CALENDAR_DoUpdate_RPattern, wParam, lParam);
  118. return bResult > 0;
  119. }
  120. BOOL CXTPCalendarCustomDataProvider::DoDelete_RPattern(CXTPCalendarRecurrencePattern* pPattern)
  121. {
  122. BOOL bResult = -1;
  123. WPARAM wParam = (WPARAM)pPattern;
  124. LPARAM lParam = (LPARAM)&bResult;
  125. SendNotification(XTP_NC_CALENDAR_DoDelete_RPattern, wParam, lParam);
  126. return bResult > 0;
  127. }
  128. CXTPCalendarEventsPtr CXTPCalendarCustomDataProvider::DoGetAllEvents_raw()
  129. {
  130. CXTPCalendarEventsPtr ptrEvents;
  131. WPARAM wParam = 0;
  132. LPARAM lParam = (LPARAM)&ptrEvents;
  133. SendNotification(XTP_NC_CALENDAR_DoGetAllEvents_raw, wParam, lParam);
  134. return ptrEvents;
  135. }
  136. CXTPCalendarEventsPtr CXTPCalendarCustomDataProvider::DoGetUpcomingEvents(COleDateTime dtFrom, COleDateTimeSpan spPeriod)
  137. {
  138. CXTPCalendarEventsPtr ptrEvents;
  139. XTP_CALENDAR_WPARAM2 wParamX2;
  140. wParamX2.wParam1 = (WPARAM)&dtFrom;
  141. wParamX2.wParam2 = (WPARAM)&spPeriod;
  142. WPARAM wParam = (WPARAM)&wParamX2;
  143. LPARAM lParam = (LPARAM)&ptrEvents;
  144. SendNotification(XTP_NC_CALENDAR_DoGetUpcomingEvents, wParam, lParam);
  145. return ptrEvents;
  146. }