home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch21 / mytool / mytoovw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-26  |  3.2 KB  |  153 lines

  1. // mytoovw.cpp : implementation of the CMytoolView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mytool.h"
  6.  
  7. #include "mytoodoc.h"
  8. #include "mytoovw.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMytoolView
  17.  
  18. IMPLEMENT_DYNCREATE(CMytoolView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CMytoolView, CView)
  21.     //{{AFX_MSG_MAP(CMytoolView)
  22.     ON_COMMAND(ID_TRYIT_MESSAGE, OnTryitMessage)
  23.     ON_COMMAND(ID_TRYIT_MUSIC, OnTryitMusic)
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CMytoolView construction/destruction
  29.  
  30. CMytoolView::CMytoolView()
  31. {
  32.     // TODO: add construction code here
  33.  
  34.      //////////////////////
  35.      // MY CODE STARTS HERE
  36.      //////////////////////
  37.  
  38.     char FileToOpen[255];
  39.  
  40.  
  41.     // Open the Kennedy WAV session
  42.     strcpy ( FileToOpen, "\\vcProg\\WAV\\LastC1M0.WAV" );
  43.     m_MusicSession = sp_OpenSession ( FileToOpen );
  44.  
  45.  
  46.     // If WAV session can not be opened, display message box.
  47.     if ( m_MusicSession < 0 )
  48.        {
  49.         CString Message, Caption;
  50.         Message = "Can't open the file: ";
  51.         Message = Message + FileToOpen;
  52.         Caption = "Error";
  53.         MessageBox ( Message, Caption );
  54.         }
  55.  
  56.      ////////////////////
  57.      // MY CODE ENDS HERE
  58.      ////////////////////
  59.  
  60. }
  61.  
  62. CMytoolView::~CMytoolView()
  63. {
  64.  
  65.      //////////////////////
  66.      // MY CODE STARTS HERE
  67.      //////////////////////
  68.  
  69.      // Close the WAV session
  70.      sp_CloseSession ( m_MusicSession );
  71.  
  72.      ////////////////////,
  73.      // MY CODE ENDS HERE
  74.      ////////////////////
  75.  
  76.  
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CMytoolView drawing
  81.  
  82. void CMytoolView::OnDraw(CDC* pDC)
  83. {
  84.     CMytoolDoc* pDoc = GetDocument();
  85.     ASSERT_VALID(pDoc);
  86.  
  87.     // TODO: add draw code for native data here
  88. }
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. // CMytoolView diagnostics
  92.  
  93. #ifdef _DEBUG
  94. void CMytoolView::AssertValid() const
  95. {
  96.     CView::AssertValid();
  97. }
  98.  
  99. void CMytoolView::Dump(CDumpContext& dc) const
  100. {
  101.     CView::Dump(dc);
  102. }
  103.  
  104. CMytoolDoc* CMytoolView::GetDocument() // non-debug version is inline
  105. {
  106.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMytoolDoc)));
  107.     return (CMytoolDoc*)m_pDocument;
  108. }
  109. #endif //_DEBUG
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CMytoolView message handlers
  113.  
  114. void CMytoolView::OnTryitMessage()
  115. {
  116.     // TODO: Add your command handler code here
  117.  
  118.  
  119.      //////////////////////
  120.      // MY CODE STARTS HERE
  121.      //////////////////////
  122.  
  123.      MessageBox ("Try It -> Message was selected");
  124.  
  125.  
  126.      ////////////////////
  127.      // MY CODE ENDS HERE
  128.      ////////////////////
  129.  
  130.     
  131. }
  132.  
  133. void CMytoolView::OnTryitMusic()
  134. {
  135.     // TODO: Add your command handler code here
  136.     
  137.      //////////////////////
  138.      // MY CODE STARTS HERE
  139.      //////////////////////
  140.  
  141.     // Play the music
  142.     sp_PlaySnd( m_MusicSession,
  143.                 SP_START_OF_FILE,
  144.                 SP_END_OF_FILE );
  145.  
  146.  
  147.  
  148.      ////////////////////
  149.      // MY CODE ENDS HERE
  150.      ////////////////////
  151.  
  152. }
  153.