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

对话框与窗口

开发平台:

Visual C++

  1. // SQLServerDataProviderView.cpp : implementation of the CSQLServerDataProviderView class
  2. //
  3. #include "stdafx.h"
  4. #include "SQLServerDataProvider.h"
  5. #include "SQLServerDataProviderDoc.h"
  6. #include "SQLServerDataProviderView.h"
  7. #include "MainFrm.h"
  8. #include "resource.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CSQLServerDataProviderView
  16. IMPLEMENT_DYNCREATE(CSQLServerDataProviderView, CXTPCalendarControlView)
  17. BEGIN_MESSAGE_MAP(CSQLServerDataProviderView, CXTPCalendarControlView)
  18. //{{AFX_MSG_MAP(CSQLServerDataProviderView)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. //    DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG_MAP
  22. // Standard printing commands
  23. ON_COMMAND(ID_FILE_PRINT, CXTPCalendarControlView::OnFilePrint)
  24. ON_COMMAND(ID_FILE_PRINT_DIRECT, CXTPCalendarControlView::OnFilePrint)
  25. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CXTPCalendarControlView::OnFilePrintPreview)
  26. ON_COMMAND(ID_CALENDAR_VIEW_DAY, OnCalendarViewDay)
  27. ON_COMMAND(ID_CALENDAR_VIEW_WORKWEEK, OnCalendarViewWorkWeek)
  28. ON_COMMAND(ID_CALENDAR_VIEW_WEEK, OnCalendarViewWeek)
  29. ON_COMMAND(ID_CALENDAR_VIEW_MONTH, OnCalendarViewMonth)
  30. ON_UPDATE_COMMAND_UI(ID_CALENDAR_VIEW_DAY, OnUpdateCalendarViewDay)
  31. ON_UPDATE_COMMAND_UI(ID_CALENDAR_VIEW_WORKWEEK, OnUpdateCalendarViewWorkWeek)
  32. ON_UPDATE_COMMAND_UI(ID_CALENDAR_VIEW_WEEK, OnUpdateCalendarViewWeek)
  33. ON_UPDATE_COMMAND_UI(ID_CALENDAR_VIEW_MONTH, OnUpdateCalendarViewMonth)
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CSQLServerDataProviderView construction/destruction
  37. CSQLServerDataProviderView::CSQLServerDataProviderView()
  38. {
  39. // TODO: add construction code here
  40. }
  41. CSQLServerDataProviderView::~CSQLServerDataProviderView()
  42. {
  43. }
  44. BOOL CSQLServerDataProviderView::PreCreateWindow(CREATESTRUCT& cs)
  45. {
  46. // TODO: Modify the Window class or styles here by modifying
  47. //  the CREATESTRUCT cs
  48. return CXTPCalendarControlView::PreCreateWindow(cs);
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CSQLServerDataProviderView drawing
  52. void CSQLServerDataProviderView::OnDraw(CDC* pDC)
  53. {
  54. CSQLServerDataProviderDoc* pDoc = GetDocument();
  55. ASSERT_VALID(pDoc);
  56. // TODO: add draw code for native data here
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CSQLServerDataProviderView diagnostics
  60. #ifdef _DEBUG
  61. void CSQLServerDataProviderView::AssertValid() const
  62. {
  63. CXTPCalendarControlView::AssertValid();
  64. }
  65. void CSQLServerDataProviderView::Dump(CDumpContext& dc) const
  66. {
  67. CXTPCalendarControlView::Dump(dc);
  68. }
  69. CSQLServerDataProviderDoc* CSQLServerDataProviderView::GetDocument() // non-debug version is inline
  70. {
  71. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSQLServerDataProviderDoc)));
  72. return (CSQLServerDataProviderDoc*)m_pDocument;
  73. }
  74. #endif //_DEBUG
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CSQLServerDataProviderView message handlers
  77. void CSQLServerDataProviderView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
  78. {   
  79. CSQLServerDataProviderDoc* pDocument = GetDocument();
  80. ASSERT(pDocument);
  81. if (!pDocument)
  82. return;
  83. if (lHint & CSQLServerDataProviderDoc::uvfSetDataProvider)
  84. {
  85. GetCalendarCtrl().SetDataProvider(pDocument->GetDataProvider_SQLServer(), FALSE);
  86. }
  87. if (lHint & CSQLServerDataProviderDoc::uvfDetachDataProvider)
  88. {
  89. GetCalendarCtrl().SetDataProvider(xtpCalendarDataProviderMemory);
  90. }
  91. if (lHint & CSQLServerDataProviderDoc::uvfPopulate)
  92. {
  93. GetCalendarCtrl().Populate();
  94. }
  95. }
  96. void CSQLServerDataProviderView::OnInitialUpdate() 
  97. {
  98. CXTPCalendarControlView::OnInitialUpdate();
  99. GetCalendarCtrl().SwitchActiveView(xtpCalendarWorkWeekView);
  100. // CXTPCalendarThemeOffice2007* pTheme2007 = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetCalendarCtrl().GetTheme());
  101. // if (pTheme2007)
  102. // {
  103. // pTheme2007->GetMonthViewPartX()->GetEventPartX()->GetEventIconsToDrawPartX()->m_ShowOccurrence = TRUE;
  104. // pTheme2007->GetMonthViewPartX()->GetEventPartX()->GetEventIconsToDrawPartX()->m_ShowException = TRUE;
  105. //
  106. // GetCalendarCtrl().GetTheme()->RefreshMetrics();
  107. // }
  108. GetCalendarCtrl().EnableReminders();
  109. CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd();
  110. if (m_wndDatePicker.GetSafeHwnd() == NULL)
  111. {
  112. m_wndDatePicker.SubclassDlgItem(IDC_DATEPICKER, &pWnd->m_dlgDatePicker);
  113. m_wndDatePicker.SetShowWeekNumbers(TRUE);
  114. m_CalendarController.SetCalendar(&GetCalendarCtrl());
  115. m_CalendarController.SetDatePicker(&m_wndDatePicker);
  116. }
  117. }
  118. void CSQLServerDataProviderView::OnCalendarViewDay() 
  119. {
  120. if(GetCalendarCtrl().GetActiveView() && 
  121. GetCalendarCtrl().GetActiveView()->GetViewType() != xtpCalendarDayView) 
  122. {
  123. GetCalendarCtrl().SwitchActiveView(xtpCalendarDayView);
  124. }
  125. }
  126. void CSQLServerDataProviderView::OnCalendarViewWorkWeek() 
  127. {
  128. if(GetCalendarCtrl().GetActiveView() && 
  129. GetCalendarCtrl().GetActiveView()->GetViewType() != xtpCalendarWorkWeekView) 
  130. {
  131. GetCalendarCtrl().SwitchActiveView(xtpCalendarWorkWeekView);
  132. }
  133. }
  134. void CSQLServerDataProviderView::OnCalendarViewWeek() 
  135. {
  136. if(GetCalendarCtrl().GetActiveView() && 
  137. GetCalendarCtrl().GetActiveView()->GetViewType() != xtpCalendarWeekView) 
  138. {
  139. GetCalendarCtrl().SwitchActiveView(xtpCalendarWeekView);
  140. }
  141. }
  142. void CSQLServerDataProviderView::OnCalendarViewMonth() 
  143. {   
  144. if(GetCalendarCtrl().GetActiveView() && 
  145. GetCalendarCtrl().GetActiveView()->GetViewType() != xtpCalendarMonthView) 
  146. {
  147. TRACE(_T("Switch to month view.n"));
  148. GetCalendarCtrl().SwitchActiveView(xtpCalendarMonthView);
  149. }
  150. }
  151. void CSQLServerDataProviderView::OnUpdateCalendarViewDay(CCmdUI* pCmdUI) 
  152. {
  153. BOOL bViewDay = FALSE;
  154. CXTPCalendarView* pView = GetCalendarCtrl().GetActiveView();
  155. if (pView && pView->GetViewType() == xtpCalendarDayView) {
  156. bViewDay = TRUE;
  157. }
  158. pCmdUI->SetCheck(bViewDay);
  159. }
  160. void CSQLServerDataProviderView::OnUpdateCalendarViewWorkWeek(CCmdUI* pCmdUI) 
  161. {
  162. BOOL bViewDays = FALSE;
  163. CXTPCalendarView* pView = GetCalendarCtrl().GetActiveView();
  164. if (pView && pView->GetViewType() == xtpCalendarWorkWeekView) {
  165. bViewDays = TRUE;
  166. }
  167. pCmdUI->SetCheck(bViewDays);
  168. }
  169. void CSQLServerDataProviderView::OnUpdateCalendarViewWeek(CCmdUI* pCmdUI) 
  170. {
  171. BOOL bViewWeek = FALSE;
  172. CXTPCalendarView* pView = GetCalendarCtrl().GetActiveView();
  173. if (pView && pView->GetViewType() == xtpCalendarWeekView) 
  174. bViewWeek = TRUE;
  175. pCmdUI->SetCheck(bViewWeek);
  176. }
  177. void CSQLServerDataProviderView::OnUpdateCalendarViewMonth(CCmdUI* pCmdUI) 
  178. {
  179. BOOL bViewMonth = FALSE;
  180. CXTPCalendarView* pView = GetCalendarCtrl().GetActiveView();
  181. if (pView && pView->GetViewType() == xtpCalendarMonthView) 
  182. bViewMonth = TRUE; 
  183. pCmdUI->SetCheck(bViewMonth);
  184. }