home *** CD-ROM | disk | FTP | other *** search
- // sayhevw.cpp : implementation of the CSayhelloView class
- //
-
- #include "stdafx.h"
- #include "sayhello.h"
-
- #include "sayhedoc.h"
- #include "sayhevw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CSayhelloView
-
- IMPLEMENT_DYNCREATE(CSayhelloView, CView)
-
- BEGIN_MESSAGE_MAP(CSayhelloView, CView)
- //{{AFX_MSG_MAP(CSayhelloView)
- ON_COMMAND(ID_FILE_SAYHELLO, OnFileSayhello)
- ON_COMMAND(ID_FILE_SAYHAVEANICEDAY, OnFileSayhaveaniceday)
- ON_COMMAND(ID_FILE_SAYGOODBYE, OnFileSaygoodbye)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CSayhelloView construction/destruction
-
- CSayhelloView::CSayhelloView()
- {
- // TODO: add construction code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- char FileToOpen[255];
-
-
- // Open the Hello.WAV session
- strcpy ( FileToOpen, "\\vcProg\\WAV\\Hello.WAV" );
- m_HelloSession = sp_OpenSession ( FileToOpen );
-
- // Open the ItsBeen1.WAV session
- strcpy ( FileToOpen, "\\vcProg\\WAV\\ItsBeen1.WAV" );
- m_ItsBeenSession = sp_OpenSession ( FileToOpen );
-
- // If WAV session can not be opened, display message box.
- if ( m_HelloSession < 0 )
- {
- CString Message, Caption;
- Message = "Can't open the file: ";
- Message = Message + FileToOpen;
- Caption = "Error";
- MessageBox ( Message, Caption );
- }
- else
- {
- // Play the Hello audio section.
- sp_PlaySnd ( m_HelloSession,
- SP_START_OF_FILE,
- 16000L);
- }
-
-
- // If WAV session can not be opened, display message box.
- if ( m_ItsBeenSession < 0 )
- {
- CString Message, Caption;
- Message = "Can't open the file: ";
- Message = Message + FileToOpen;
- Caption = "Error";
- MessageBox ( Message, Caption );
- }
-
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- CSayhelloView::~CSayhelloView()
- {
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- sp_PlaySnd ( m_ItsBeenSession,
- SP_START_OF_FILE,
- SP_END_OF_FILE );
-
- sp_CloseSession ( m_HelloSession );
- sp_CloseSession ( m_ItsBeenSession );
-
-
- ////////////////////,
- // MY CODE ENDS HERE
- ////////////////////
-
-
-
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CSayhelloView drawing
-
- void CSayhelloView::OnDraw(CDC* pDC)
- {
- CSayhelloDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CSayhelloView diagnostics
-
- #ifdef _DEBUG
- void CSayhelloView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CSayhelloView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CSayhelloDoc* CSayhelloView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSayhelloDoc)));
- return (CSayhelloDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CSayhelloView message handlers
-
- void CSayhelloView::OnFileSayhello()
- {
- // TODO: Add your command handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- sp_PlaySnd ( m_HelloSession,
- SP_START_OF_FILE,
- 16000L );
-
- ////////////////////,
- // MY CODE ENDS HERE
- ////////////////////
-
-
- }
-
- void CSayhelloView::OnFileSayhaveaniceday()
- {
- // TODO: Add your command handler code here
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- sp_PlaySnd ( m_HelloSession,
- 18000L,
- 50000L );
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CSayhelloView::OnFileSaygoodbye()
- {
- // TODO: Add your command handler code here
-
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- sp_PlaySnd ( m_HelloSession,
- 50000L,
- SP_END_OF_FILE );
-
-
- ////////////////////,
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-