home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch24 / avi / aviview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-05  |  2.9 KB  |  134 lines

  1. // aviview.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "avi.h"
  6. #include "aviview.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CAviView
  15.  
  16. IMPLEMENT_DYNCREATE(CAviView, CFormView)
  17.  
  18. CAviView::CAviView()
  19.     : CFormView(CAviView::IDD)
  20. {
  21.     //{{AFX_DATA_INIT(CAviView)
  22.     m_avi = NULL;
  23.     m_AutoRepeat = FALSE;
  24.     m_Silent = FALSE;
  25.     //}}AFX_DATA_INIT
  26. }
  27.  
  28. CAviView::~CAviView()
  29. {
  30. }
  31.  
  32. void CAviView::DoDataExchange(CDataExchange* pDX)
  33. {
  34.     CFormView::DoDataExchange(pDX);
  35.     //{{AFX_DATA_MAP(CAviView)
  36.     DDX_VBControl(pDX, IDC_TEGOMM_AVI, m_avi);
  37.     DDX_Check(pDX, IDC_AUTO_REPEAT, m_AutoRepeat);
  38.     DDX_Check(pDX, IDC_SILENT, m_Silent);
  39.     //}}AFX_DATA_MAP
  40. }
  41.  
  42.  
  43. BEGIN_MESSAGE_MAP(CAviView, CFormView)
  44.     //{{AFX_MSG_MAP(CAviView)
  45.     ON_VBXEVENT(VBN_DONE, IDC_TEGOMM_AVI, OnDoneTegommAvi)
  46.     ON_BN_CLICKED(IDC_SILENT, OnSilent)
  47.     //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49.  
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CAviView message handlers
  53.  
  54. //////////////////////
  55. // MY CODE STARTS HERE
  56. //////////////////////
  57.  
  58. void CAviView::OnInitialUpdate()
  59. {
  60.  
  61.    // Call the base class function.
  62.    CFormView::OnInitialUpdate();
  63.  
  64.    // Open the MOVIE.AVI file.
  65.    m_avi->SetStrProperty("DeviceType","AVIVideo");
  66.    m_avi->SetStrProperty("FileName",
  67.                          "\\VCPROG\\AVI\\MOVIE.AVI" );
  68.    m_avi->SetStrProperty("Command", "Open");
  69.  
  70.    // Movie should play inside application's window.
  71.    m_avi->SetNumProperty("hWndDisplay",(int)m_hWnd);
  72.  
  73. }
  74.  
  75. ////////////////////
  76. // MY CODE ENDS HERE
  77. ////////////////////
  78.  
  79. void CAviView::OnDoneTegommAvi(UINT, int, CWnd*, LPVOID)
  80. {
  81. // TODO: Add your VBX event notification handler code here
  82.  
  83. ///////////////////////
  84. // MY CODE STARTS HERE
  85. //////////////////////
  86.  
  87. // Update the variable m_AutoRepeat.
  88. UpdateData(TRUE);
  89.  
  90. // Get current position.
  91. long position = m_avi->GetNumProperty("Position");
  92.  
  93. // Get total length.
  94. long length = m_avi->GetNumProperty("Length");
  95.  
  96. // If current position is end position, rewind the tape.
  97.    if (position == length)
  98.       {
  99.       m_avi->SetStrProperty("Command", "Prev");
  100.  
  101.       // If Auto Repeat check box is checked, play again.
  102.       if (m_AutoRepeat == TRUE )
  103.          {
  104.          m_avi->SetStrProperty("Command", "Play");
  105.          }
  106.  
  107.       }
  108.  
  109. ////////////////////
  110. // MY CODE ENDS HERE
  111. ////////////////////
  112.     
  113. }
  114.  
  115. void CAviView::OnSilent()
  116. {
  117. // TODO: Add your control notification handler code here
  118.  
  119.    //////////////////////
  120.    // MY CODE STARTS HERE
  121.    //////////////////////
  122.  
  123.    // Update the m_Silent variable.
  124.    UpdateData(TRUE);
  125.  
  126.    // Set the Silent property.
  127.    m_avi->SetNumProperty("Silent", m_Silent);
  128.  
  129.    ////////////////////
  130.    // MY CODE ENDS HERE
  131.    ////////////////////
  132.     
  133. }
  134.