home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / schedvbx / samples.z / VCSAMVW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-17  |  4.8 KB  |  203 lines

  1. // vcsamvw.cpp : implementation of the CVcsamp1View class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vcsamp1.h"
  6.  
  7. #include "schedvbx.h"
  8.  
  9. #include "vcsamdoc.h"
  10. #include "vcsamvw.h"
  11.  
  12. #include "scheddlg.h"
  13.  
  14. #ifdef _DEBUG
  15. #undef THIS_FILE
  16. static char BASED_CODE THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CVcsamp1View
  21.  
  22. IMPLEMENT_DYNCREATE(CVcsamp1View, CView)
  23.  
  24. BEGIN_MESSAGE_MAP(CVcsamp1View, CView)
  25.     //{{AFX_MSG_MAP(CVcsamp1View)
  26.     ON_COMMAND(IDM_DIALOG, OnDialog)
  27.     ON_WM_SIZE()
  28.     ON_COMMAND(IDM_RESOURCEVIEW, OnResourceview)
  29.     ON_COMMAND(IDM_YEARLYVIEW, OnYearlyview)
  30.     ON_COMMAND(IDM_MONTHLYVIEW, OnMonthlyview)
  31.     ON_COMMAND(IDM_WEEKLYVIEW, OnWeeklyview)
  32.     ON_COMMAND(IDM_DAILYVIEW, OnDailyview)
  33.     //}}AFX_MSG_MAP
  34.     // Standard printing commands
  35.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  36.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CVcsamp1View construction/destruction
  41.  
  42. CVcsamp1View::CVcsamp1View()
  43. {
  44.     m_SchedVBX = NULL;        
  45. }
  46.  
  47. CVcsamp1View::~CVcsamp1View()
  48. {
  49.     if (m_SchedVBX)
  50.         delete m_SchedVBX;
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CVcsamp1View drawing
  55.  
  56. void CVcsamp1View::OnDraw(CDC* pDC)
  57. {
  58.     CVcsamp1Doc* pDoc = GetDocument();
  59.     ASSERT_VALID(pDoc);
  60.  
  61.     // TODO: add draw code for native data here
  62. }
  63.  
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CVcsamp1View printing
  66.  
  67. BOOL CVcsamp1View::OnPreparePrinting(CPrintInfo* pInfo)
  68. {
  69.     // default preparation
  70.     return DoPreparePrinting(pInfo);
  71. }
  72.  
  73. void CVcsamp1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  74. {
  75.     // TODO: add extra initialization before printing
  76. }
  77.  
  78. void CVcsamp1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  79. {
  80.     // TODO: add cleanup after printing
  81. }
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CVcsamp1View diagnostics
  85.  
  86. #ifdef _DEBUG
  87. void CVcsamp1View::AssertValid() const
  88. {
  89.     CView::AssertValid();
  90. }
  91.  
  92. void CVcsamp1View::Dump(CDumpContext& dc) const
  93. {
  94.     CView::Dump(dc);
  95. }
  96.  
  97. CVcsamp1Doc* CVcsamp1View::GetDocument() // non-debug version is inline
  98. {
  99.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVcsamp1Doc)));
  100.     return (CVcsamp1Doc*)m_pDocument;
  101. }
  102. #endif //_DEBUG
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CVcsamp1View message handlers
  106.  
  107. void CVcsamp1View::OnDialog()
  108. {
  109.     SchedDlg dlg;
  110.     
  111.     dlg.DoModal();
  112.     
  113. }
  114.  
  115. void CVcsamp1View::OnInitialUpdate()
  116. {
  117.     if (m_SchedVBX) return;
  118.  
  119.     m_SchedVBX = new CScheduleVBX();
  120.     
  121.     CRect rect;
  122.  
  123.     GetClientRect(&rect);
  124.  
  125.     m_SchedVBX->Create(WS_CHILD, rect, this, 100);    
  126.     
  127.     m_SchedVBX->SetTSDateTimeBeg(0, "1/1/95");
  128.     m_SchedVBX->SetTSDateTimeEnd(0, "1/1/96");
  129.     m_SchedVBX->SetTSDateTimeView(0, "1/12/95 8:00AM");
  130.  
  131.     m_SchedVBX->SetResLoad("RESOURCE.TXT");
  132.     m_SchedVBX->SetTBLoad("TIMEBLKS.TXT");
  133.  
  134.     m_SchedVBX->SetFocus();
  135. }
  136.  
  137. void CVcsamp1View::OnSize(UINT nType, int cx, int cy)
  138. {
  139.     CView::OnSize(nType, cx, cy);
  140.  
  141.     if (m_SchedVBX)
  142.         m_SchedVBX->MoveWindow(0,0,cx,cy,TRUE);
  143. }
  144.  
  145. void CVcsamp1View::OnResourceview()
  146. {
  147.     if (m_SchedVBX) {
  148.         m_SchedVBX->SetRedraw(FALSE);
  149.         // set minor TS to days
  150.         m_SchedVBX->SetTSMinor(0, CScheduleVBX::TS_Days);
  151.         m_SchedVBX->SetDisplayMode(CScheduleVBX::DisplayMode_Resource);
  152.         m_SchedVBX->SetRedraw(TRUE);
  153.     }
  154. }
  155.  
  156. void CVcsamp1View::OnYearlyview()
  157. {
  158.     if (m_SchedVBX) {
  159.         m_SchedVBX->SetRedraw(FALSE);
  160.         // set minor TS to years - so its out of the way
  161.         //    we want to use defaults for this view
  162.         m_SchedVBX->SetTSMinor(0, CScheduleVBX::TS_Years);
  163.         m_SchedVBX->SetDisplayMode(CScheduleVBX::DisplayMode_YearlyHorz);
  164.         m_SchedVBX->SetRedraw(TRUE);
  165.     }
  166. }
  167.  
  168. void CVcsamp1View::OnMonthlyview()
  169. {
  170.     if (m_SchedVBX) {
  171.         m_SchedVBX->SetRedraw(FALSE);
  172.         // set minor TS to years - so its out of the way
  173.         //    we want to use defaults for this view
  174.         m_SchedVBX->SetTSMinor(0, CScheduleVBX::TS_Years);
  175.         m_SchedVBX->SetDisplayMode(CScheduleVBX::DisplayMode_MonthlyHorz);
  176.         m_SchedVBX->SetRedraw(TRUE);
  177.     }
  178. }
  179.  
  180. void CVcsamp1View::OnWeeklyview()
  181. {
  182.     if (m_SchedVBX) {
  183.         m_SchedVBX->SetRedraw(FALSE);
  184.         // set minor TS to years - so its out of the way
  185.         //    we want to use defaults for this view
  186.         m_SchedVBX->SetTSMinor(0, CScheduleVBX::TS_Years);
  187.         m_SchedVBX->SetDisplayMode(CScheduleVBX::DisplayMode_WeeklyVert);
  188.         m_SchedVBX->SetRedraw(TRUE);
  189.     }
  190. }
  191.  
  192. void CVcsamp1View::OnDailyview()
  193. {
  194.     if (m_SchedVBX) {
  195.         m_SchedVBX->SetRedraw(FALSE);
  196.         // set minor TS to years - so its out of the way
  197.         //    we want to use defaults for this view
  198.         m_SchedVBX->SetTSMinor(0, CScheduleVBX::TS_Years);
  199.         m_SchedVBX->SetDisplayMode(CScheduleVBX::DisplayMode_DailyVert);
  200.         m_SchedVBX->SetRedraw(TRUE);
  201.     }
  202. }
  203.