home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / appendix / multi / multivw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-18  |  9.7 KB  |  374 lines

  1. // multivw.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "multi.h"
  6. #include "multivw.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMultiView
  15.  
  16. IMPLEMENT_DYNCREATE(CMultiView, CFormView)
  17.  
  18. CMultiView::CMultiView()
  19.     : CFormView(CMultiView::IDD)
  20. {
  21.     //{{AFX_DATA_INIT(CMultiView)
  22.     m_cd = NULL;
  23.     m_mid = NULL;
  24.     m_pc = NULL;
  25.     m_wav = NULL;
  26.     m_avi = NULL;
  27.     m_Silent = FALSE;
  28.     m_PcSong = -1;
  29.     m_AutoRepeat = FALSE;
  30.     //}}AFX_DATA_INIT
  31. }
  32.  
  33. CMultiView::~CMultiView()
  34. {
  35. }
  36.  
  37. void CMultiView::DoDataExchange(CDataExchange* pDX)
  38. {
  39.     CFormView::DoDataExchange(pDX);
  40.     //{{AFX_DATA_MAP(CMultiView)
  41.     DDX_VBControl(pDX, IDC_TEGOMM_CD, m_cd);
  42.     DDX_VBControl(pDX, IDC_TEGOMM_MID, m_mid);
  43.     DDX_VBControl(pDX, IDC_TEGOMM_PC, m_pc);
  44.     DDX_VBControl(pDX, IDC_TEGOMM_WAV, m_wav);
  45.     DDX_VBControl(pDX, IDC_TEGOMM_AVI, m_avi);
  46.     DDX_Check(pDX, IDC_SILENT, m_Silent);
  47.     DDX_Radio(pDX, IDC_RADIO_PC1, m_PcSong);
  48.     DDX_Check(pDX, IDC_AUTO_REPEAT, m_AutoRepeat);
  49.     //}}AFX_DATA_MAP
  50. }
  51.  
  52.  
  53. BEGIN_MESSAGE_MAP(CMultiView, CFormView)
  54.     //{{AFX_MSG_MAP(CMultiView)
  55.     ON_BN_CLICKED(IDC_RADIO_PC1, OnRadioPc1)
  56.     ON_BN_CLICKED(IDC_RADIO_PC2, OnRadioPc2)
  57.     ON_BN_CLICKED(IDC_RADIO_PC3, OnRadioPc3)
  58.     ON_BN_CLICKED(IDC_BUTTON_LOAD, OnButtonLoad)
  59.     ON_WM_PAINT()
  60.     ON_VBXEVENT(VBN_DONE, IDC_TEGOMM_AVI, OnDoneTegommAvi)
  61.     ON_VBXEVENT(VBN_DONE, IDC_TEGOMM_MID, OnDoneTegommMid)
  62.     ON_VBXEVENT(VBN_DONE, IDC_TEGOMM_PC, OnDoneTegommPc)
  63.     ON_VBXEVENT(VBN_DONE, IDC_TEGOMM_WAV, OnDoneTegommWav)
  64.     ON_BN_CLICKED(IDC_SILENT, OnSilent)
  65.     //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67.  
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CMultiView message handlers
  71.  
  72. //////////////////////
  73. // MY CODE STARTS HERE
  74. //////////////////////
  75.  
  76. void CMultiView::OnInitialUpdate()
  77. {
  78.  
  79.    // Call the base class function.
  80.    CFormView::OnInitialUpdate();
  81.  
  82.    // Initialize the m_PcSong variable.
  83.    // (the song number for the m_pc multimedia control).
  84.    m_PcSong=0;
  85.    UpdateData(FALSE);
  86.       
  87.    // Open the WAV file for PC Speaker.
  88.    m_pc->SetStrProperty("DeviceType","PCSpeaker");
  89.    m_pc->SetStrProperty("FileName",
  90.                          "\\VCPROG\\WAV\\BOURB1M1.WAV" );
  91.    m_pc->SetStrProperty("Command", "Open");
  92.  
  93.    // Was the WAV file opened successfully?
  94.    if ( m_pc->GetNumProperty("Error") != 0 )
  95.       MessageBox("Cannot open the file "+m_pc->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  96.    
  97.    // Open the MOVIE.AVI file.
  98.    m_avi->SetStrProperty("DeviceType","AVIVideo");
  99.    m_avi->SetStrProperty("FileName",
  100.                          "\\VCPROG\\AVI\\MOVIE.AVI" );
  101.    m_avi->SetStrProperty("Command", "Open");
  102.  
  103.    // Was the AVI file opened successfully?
  104.    if ( m_avi->GetNumProperty("Error") != 0 )
  105.       MessageBox("Cannot open the file "+m_avi->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  106.  
  107.    // Movie should play inside application's window.
  108.    m_avi->SetNumProperty("hWndDisplay",(int)m_hWnd);
  109.  
  110.    // Open the WAV file (for the sound card).
  111.    m_wav->SetStrProperty("DeviceType","WaveAudio");
  112.    m_wav->SetStrProperty("FileName",
  113.                          "\\VCPROG\\WAV\\HOLID1M1.WAV" );
  114.    m_wav->SetStrProperty("Command", "Open");
  115.    
  116.    // Was the WAV file opened successfully?
  117.    if ( m_wav->GetNumProperty("Error") != 0 )
  118.       MessageBox("Cannot open the file "+m_wav->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  119.  
  120.    // Open the MID file.
  121.    m_mid->SetStrProperty("DeviceType","Sequencer");
  122.    m_mid->SetStrProperty("FileName",
  123.                          "\\VCPROG\\MIDI\\PICKIN6.MID" );
  124.    m_mid->SetStrProperty("Command", "Open");
  125.  
  126.    // Was the MID file opened successfully?
  127.    if ( m_mid->GetNumProperty("Error") != 0 )
  128.       MessageBox("Cannot open the file "+m_mid->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  129.  
  130.    // Try to open the m_cd multimedia control.
  131.    // Note: The user can also open the m_cd multimedia
  132.    //       control by clicking the IDC_BUTTON_LOAD button.
  133.    m_cd->SetStrProperty("DeviceType","CDAudio");
  134.    m_cd->SetStrProperty("Command", "Open");   
  135.  
  136. }
  137.  
  138. ////////////////////
  139. // MY CODE ENDS HERE
  140. //////////////////// 
  141.  
  142.  
  143. void CMultiView::OnRadioPc1()
  144. {
  145.    // TODO: Add your control notification handler code here
  146.  
  147.    ///////////////////////
  148.    // MY CODE STARTS HERE
  149.    //////////////////////
  150.    
  151.    // Open WAV file number 1.
  152.    m_pc->SetStrProperty("FileName",
  153.                          "\\VCPROG\\WAV\\BOURB1M1.WAV" );
  154.    m_pc->SetStrProperty("Command", "Open");
  155.  
  156.    // Was the WAV file opened successfully?
  157.    if ( m_pc->GetNumProperty("Error") != 0 )
  158.       MessageBox("Cannot open the file "+m_pc->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  159.    
  160.    // Update the variable of the radio button.
  161.    UpdateData(TRUE);
  162.    
  163.    ////////////////////
  164.    // MY CODE ENDS HERE
  165.    ////////////////////
  166.  
  167.  
  168.     
  169. }
  170.  
  171. void CMultiView::OnRadioPc2()
  172. {
  173.    // TODO: Add your control notification handler code here
  174.  
  175.    ///////////////////////
  176.    // MY CODE STARTS HERE
  177.    //////////////////////
  178.  
  179.    // Open WAV file number 2.
  180.    m_pc->SetStrProperty("FileName",
  181.                          "\\VCPROG\\WAV\\STROL1M1.WAV" );
  182.    m_pc->SetStrProperty("Command", "Open");
  183.  
  184.    // Was the WAV file opened successfully?
  185.    if ( m_pc->GetNumProperty("Error") != 0 )
  186.       MessageBox("Cannot open the file "+m_pc->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  187.    
  188.    // Update the variable of the radio button.
  189.    UpdateData(TRUE);
  190.    
  191.    
  192.    ////////////////////
  193.    // MY CODE ENDS HERE
  194.    ////////////////////
  195.  
  196. }
  197.  
  198. void CMultiView::OnRadioPc3()
  199. {
  200.    // TODO: Add your control notification handler code here
  201.  
  202.    ///////////////////////
  203.    // MY CODE STARTS HERE
  204.    //////////////////////
  205.    
  206.    // Open WAV file number 3.
  207.    m_pc->SetStrProperty("FileName",
  208.                          "\\VCPROG\\WAV\\8KENNED3.WAV" );
  209.    m_pc->SetStrProperty("Command", "Open");
  210.  
  211.    // Was the WAV file opened successfully?
  212.    if ( m_pc->GetNumProperty("Error") != 0 )
  213.       MessageBox("Cannot open the file "+m_pc->GetStrProperty("FileName"), "Error", MB_ICONSTOP); 
  214.  
  215.    // Update the variable of the radio button.
  216.    UpdateData(TRUE);
  217.    
  218.    ////////////////////
  219.    // MY CODE ENDS HERE
  220.    ////////////////////
  221. }
  222.  
  223. void CMultiView::OnButtonLoad()
  224. {
  225.     // TODO: Add your control notification handler code here
  226.     
  227.     ///////////////////////
  228.     // MY CODE STARTS HERE
  229.     //////////////////////
  230.  
  231.     // Issue an Open command to the CD device.
  232.     m_cd->SetStrProperty("Command", "Open");
  233.  
  234.  
  235.     // Was the CD Audio device opened successfully?
  236.     if ( m_cd->GetNumProperty("Error") != 0 )
  237.        MessageBox("Cannot open the CD Audio device.", "Error", MB_ICONSTOP ); 
  238.     
  239.     ////////////////////
  240.     // MY CODE ENDS HERE
  241.     ////////////////////
  242.  
  243. }
  244.  
  245. void CMultiView::OnPaint()
  246. {
  247.     CPaintDC dc(this); // device context for painting
  248.     
  249.     // TODO: Add your message handler code here
  250.  
  251.     ///////////////////////
  252.     // MY CODE STARTS HERE
  253.     //////////////////////
  254.     
  255.     // Repaint the current frame.
  256.     m_avi->SetStrProperty( "Command", "Repaint" );
  257.     
  258.     ////////////////////
  259.     // MY CODE ENDS HERE
  260.     ////////////////////
  261.  
  262.  
  263.  
  264.     
  265.     // Do not call CFormView::OnPaint() for painting messages
  266. }
  267.  
  268. void CMultiView::OnDoneTegommAvi(UINT, int, CWnd*, LPVOID)
  269. {
  270.   // TODO: Add your VBX event notification handler code here
  271.  
  272. ///////////////////////
  273. // MY CODE STARTS HERE
  274. //////////////////////
  275.  
  276. // Update the variable m_AutoRepeat.
  277. UpdateData(TRUE);
  278.  
  279. // Get current position.
  280. long position = m_avi->GetNumProperty("Position");
  281.  
  282. // Get total length.
  283. long length = m_avi->GetNumProperty("Length");
  284.  
  285. // If current position is end position, rewind the tape.
  286.    if (position == length)
  287.       {
  288.       m_avi->SetStrProperty("Command", "Prev");
  289.  
  290.       // If Auto Repeat check box is checked, play again.
  291.       if (m_AutoRepeat == TRUE )
  292.          {
  293.          m_avi->SetStrProperty("Command", "Play");
  294.          }
  295.  
  296.       }
  297.  
  298. ////////////////////
  299. // MY CODE ENDS HERE
  300. ////////////////////
  301.     
  302. }
  303.  
  304. void CMultiView::OnDoneTegommMid(UINT, int, CWnd*, LPVOID)
  305. {
  306.   // TODO: Add your VBX event notification handler code here
  307.  
  308.   //////////////////////
  309.   // MY CODE STARTS HERE
  310.   //////////////////////
  311.    
  312.   if ( m_mid->GetNumProperty("Position") == m_mid->GetNumProperty("Length") )
  313.      m_mid->SetStrProperty("Command","Prev");
  314.     
  315.   ////////////////////
  316.   // MY CODE ENDS HERE
  317.   ////////////////////
  318.     
  319. }
  320.  
  321. void CMultiView::OnDoneTegommPc(UINT, int, CWnd*, LPVOID)
  322. {
  323.   // TODO: Add your VBX event notification handler code here
  324.     
  325.   //////////////////////
  326.   // MY CODE STARTS HERE
  327.   //////////////////////
  328.    
  329.   if ( m_pc->GetNumProperty("Position") == m_pc->GetNumProperty("Length") )
  330.      m_pc->SetStrProperty("Command","Prev");
  331.     
  332.   ////////////////////
  333.   // MY CODE ENDS HERE
  334.   ////////////////////
  335.     
  336. }
  337.  
  338. void CMultiView::OnDoneTegommWav(UINT, int, CWnd*, LPVOID)
  339. {
  340.   // TODO: Add your VBX event notification handler code here
  341.     
  342.   //////////////////////
  343.   // MY CODE STARTS HERE
  344.   //////////////////////
  345.    
  346.   if ( m_wav->GetNumProperty("Position") == m_wav->GetNumProperty("Length") )
  347.      m_wav->SetStrProperty("Command","Prev");
  348.     
  349.   ////////////////////
  350.   // MY CODE ENDS HERE
  351.   ////////////////////
  352.     
  353. }
  354.  
  355. void CMultiView::OnSilent()
  356. {
  357.    // TODO: Add your control notification handler code here
  358.  
  359.    //////////////////////
  360.    // MY CODE STARTS HERE
  361.    //////////////////////
  362.  
  363.    // Update the m_Silent variable.
  364.    UpdateData(TRUE);
  365.  
  366.    // Set the Silent property.
  367.    m_avi->SetNumProperty("Silent", m_Silent);
  368.  
  369.    ////////////////////
  370.    // MY CODE ENDS HERE
  371.    ////////////////////
  372.  
  373. }
  374.