home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch20 / picmenu / picmevw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-26  |  6.0 KB  |  250 lines

  1. // picmevw.cpp : implementation of the CPicmenuView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "picmenu.h"
  6.  
  7. #include "picmedoc.h"
  8. #include "picmevw.h"
  9.  
  10. #ifdef _DEBUG
  11. #undef THIS_FILE
  12. static char BASED_CODE THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CPicmenuView
  17.  
  18. IMPLEMENT_DYNCREATE(CPicmenuView, CView)
  19.  
  20. BEGIN_MESSAGE_MAP(CPicmenuView, CView)
  21.     //{{AFX_MSG_MAP(CPicmenuView)
  22.     ON_COMMAND(ID_PICTUREMENU_ITEM1, OnPicturemenuItem1)
  23.     ON_COMMAND(ID_PICTUREMENU_ITEM2, OnPicturemenuItem2)
  24.     ON_COMMAND(ID_PICTUREMENU_ITEM3, OnPicturemenuItem3)
  25.     ON_COMMAND(ID_PICTUREMENU_ITEM4, OnPicturemenuItem4)
  26.     ON_COMMAND(ID_PICTUREMENU_ITEM5, OnPicturemenuItem5)
  27.     //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CPicmenuView construction/destruction
  32.  
  33. CPicmenuView::CPicmenuView()
  34. {
  35.     // TODO: add construction code here
  36.  
  37.  
  38.      //////////////////////
  39.      // MY CODE STARTS HERE
  40.      //////////////////////
  41.  
  42.     char FileToOpen[255];
  43.  
  44.  
  45.     // Open the Kennedy WAV session
  46.     strcpy ( FileToOpen, "\\vcProg\\WAV\\8Kenned3.WAV" );
  47.     m_KennedySession = sp_OpenSession ( FileToOpen );
  48.  
  49.  
  50.     // If WAV session can not be opened, display message box.
  51.     if ( m_KennedySession < 0 )
  52.        {
  53.        CString Message, Caption;
  54.         Message = "Can't open the file: ";
  55.         Message = Message + FileToOpen;
  56.         Caption = "Error";
  57.         MessageBox ( Message, Caption );
  58.         }
  59.  
  60.      ////////////////////
  61.      // MY CODE ENDS HERE
  62.      ////////////////////
  63. }
  64.  
  65. CPicmenuView::~CPicmenuView()
  66. {
  67.  
  68.      //////////////////////
  69.      // MY CODE STARTS HERE
  70.      //////////////////////
  71.  
  72.      sp_CloseSession ( m_KennedySession );
  73.  
  74.  
  75.      ////////////////////,
  76.      // MY CODE ENDS HERE
  77.  
  78. }
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CPicmenuView drawing
  82.  
  83. void CPicmenuView::OnDraw(CDC* pDC)
  84. {
  85.     CPicmenuDoc* pDoc = GetDocument();
  86.     ASSERT_VALID(pDoc);
  87.  
  88.     // TODO: add draw code for native data here
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CPicmenuView diagnostics
  93.  
  94. #ifdef _DEBUG
  95. void CPicmenuView::AssertValid() const
  96. {
  97.     CView::AssertValid();
  98. }
  99.  
  100. void CPicmenuView::Dump(CDumpContext& dc) const
  101. {
  102.     CView::Dump(dc);
  103. }
  104.  
  105. CPicmenuDoc* CPicmenuView::GetDocument() // non-debug version is inline
  106. {
  107.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPicmenuDoc)));
  108.     return (CPicmenuDoc*)m_pDocument;
  109. }
  110. #endif //_DEBUG
  111.  
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CPicmenuView message handlers
  114.  
  115. void CPicmenuView::OnPicturemenuItem1()
  116. {
  117.     // TODO: Add your command handler code here
  118.  
  119.      //////////////////////
  120.      // MY CODE STARTS HERE
  121.      //////////////////////
  122.  
  123.      // Cause a WM_PAINT message
  124.      Invalidate();
  125.  
  126.      CString Message;
  127.  
  128.      CClientDC dc(this);
  129.  
  130.  
  131.      // So my fellow Americans
  132.      Message = "So my fellow Americans";
  133.      dc.TextOut ( 10,                     // X coordinate
  134.                   20,                     // Y coordinate
  135.                   Message,                // The text
  136.                   Message.GetLength() );  // Length of text
  137.  
  138.      sp_PlaySnd ( m_KennedySession,
  139.                   0,
  140.                   25980 );
  141.  
  142.       // Ask not
  143.      Message = "Ask not";
  144.      dc.TextOut ( 10,                     // X coordinate
  145.                   40,                     // Y coordinate
  146.                   Message,                // The text
  147.                   Message.GetLength() );  // Length of text
  148.  
  149.       sp_PlaySnd ( m_KennedySession,
  150.                   25980,
  151.                   54680 );
  152.          
  153.       // What your country can do for you
  154.       Message = "What your country can do for you";
  155.       dc.TextOut ( 10,                     // X coordinate
  156.                    60,                     // Y coordinate
  157.                    Message,                // The text
  158.                    Message.GetLength() );  // Length of text
  159.  
  160.       sp_PlaySnd ( m_KennedySession,
  161.                    54680,
  162.                    84090 );
  163.  
  164.       // ask what you can do for your country
  165.       Message = "ask what you can do for your country";
  166.       dc.TextOut ( 10,                     // X coordinate
  167.                    80,                     // Y coordinate
  168.                    Message,                // The text
  169.                    Message.GetLength() );  // Length of text
  170.  
  171.        sp_PlaySnd ( m_KennedySession,
  172.                     84090,
  173.                     107619 );
  174.  
  175.       // People cheering
  176.       sp_PlaySnd ( m_KennedySession,
  177.                    107619,
  178.                    SP_END_OF_FILE );
  179.  
  180.      ////////////////////
  181.      // MY CODE ENDS HERE
  182.      ////////////////////
  183.  
  184.  
  185. }
  186.  
  187. void CPicmenuView::OnPicturemenuItem2()
  188. {
  189.     // TODO: Add your command handler code here
  190.     
  191.      //////////////////////
  192.      // MY CODE STARTS HERE
  193.      //////////////////////
  194.  
  195.      MessageBox ("You selected the second item");
  196.  
  197.      ////////////////////
  198.      // MY CODE ENDS HERE
  199.      ////////////////////
  200.  
  201. }
  202.  
  203. void CPicmenuView::OnPicturemenuItem3()
  204. {
  205.     // TODO: Add your command handler code here
  206.  
  207.      //////////////////////
  208.      // MY CODE STARTS HERE
  209.      //////////////////////
  210.  
  211.      MessageBox ("You selected the third item");
  212.  
  213.      ////////////////////
  214.      // MY CODE ENDS HERE
  215.      ////////////////////
  216.     
  217. }
  218.  
  219. void CPicmenuView::OnPicturemenuItem4()
  220. {
  221.     // TODO: Add your command handler code here
  222.  
  223.      //////////////////////
  224.      // MY CODE STARTS HERE
  225.      //////////////////////
  226.  
  227.      MessageBox ("You selected the 4th item");
  228.  
  229.      ////////////////////
  230.      // MY CODE ENDS HERE
  231.      ////////////////////
  232.  
  233. }
  234.  
  235. void CPicmenuView::OnPicturemenuItem5()
  236. {
  237.     // TODO: Add your command handler code here
  238.     
  239.      //////////////////////
  240.      // MY CODE STARTS HERE
  241.      //////////////////////
  242.  
  243.      MessageBox ("You selected the 5th item");
  244.  
  245.      ////////////////////
  246.      // MY CODE ENDS HERE
  247.      ////////////////////
  248.  
  249. }
  250.