home *** CD-ROM | disk | FTP | other *** search
- // myradvw.cpp : implementation of the CMyradioView class
- //
-
- #include "stdafx.h"
- #include "myradio.h"
-
- #include "myraddoc.h"
- #include "myradvw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMyradioView
-
- IMPLEMENT_DYNCREATE(CMyradioView, CView)
-
- BEGIN_MESSAGE_MAP(CMyradioView, CView)
- //{{AFX_MSG_MAP(CMyradioView)
- ON_COMMAND(ID_FILE_TRYIT, OnFileTryit)
- ON_COMMAND(ID_FILE_BEEP, OnFileBeep)
- ON_COMMAND(ID_FILE_PLAYME, OnFilePlayme)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMyradioView construction/destruction
-
- CMyradioView::CMyradioView()
- {
- // TODO: add construction code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Declare local variables
- char FileToOpen[255];
- CString Message, Caption;
-
- // Open a WAV session for Hello.WAV
- strcpy ( FileToOpen, "\\vcProg\\WAV\\Hello.WAV" );
- m_HelloSession = sp_OpenSession ( FileToOpen );
-
- // If WAV session can't be opened, display an error
- // message box.
- if ( m_HelloSession < 0 )
- {
- Message = "Can't open the file: ";
- Message = Message + FileToOpen;
- Caption = "Error";
- MessageBox ( Message, Caption );
- }
-
- // Open a WAV session for 8Kenned3.WAV
- strcpy ( FileToOpen, "\\vcProg\\WAV\\8Kenned3.WAV" );
- m_KennedySession = sp_OpenSession ( FileToOpen );
-
- // If WAV session can't be opened, display an error
- // message box.
- if ( m_KennedySession < 0 )
- {
- Message = "Can't open the file: ";
- Message = Message + FileToOpen;
- Caption = "Error";
- MessageBox ( Message, Caption );
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- CMyradioView::~CMyradioView()
- {
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- sp_PlaySnd ( m_HelloSession,
- 52160L,
- SP_END_OF_FILE );
-
- sp_CloseSession ( m_HelloSession );
- sp_CloseSession ( m_KennedySession );
-
-
- ////////////////////,
- // MY CODE ENDS HERE
- ////////////////////
-
-
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMyradioView drawing
-
- void CMyradioView::OnDraw(CDC* pDC)
- {
- CMyradioDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMyradioView diagnostics
-
- #ifdef _DEBUG
- void CMyradioView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CMyradioView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CMyradioDoc* CMyradioView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyradioDoc)));
- return (CMyradioDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMyradioView message handlers
-
- void CMyradioView::OnFileTryit()
- {
- // TODO: Add your command handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Display the dlg dialog box.
- dlg.DoModal();
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CMyradioView::OnFileBeep()
- {
- // TODO: Add your command handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // User selected Beep from the File menu, so beep.
- DWORD start;
- switch (dlg.m_BeepStatus)
- {
- case 0:
- // Beep
- MessageBeep(-1);
- break;
- case 1:
- // Beep
- MessageBeep(-1);
-
- // 1 second delay
- start = GetTickCount();
- while ( GetTickCount() < start + 1000 )
- ;
-
- // Beep
- MessageBeep(-1);
- break;
- case 2:
- // Beep
- MessageBeep(-1);
-
- // 1 second delay
- start = GetTickCount();
- while ( GetTickCount() < start + 1000 )
- ;
-
- // Beep
- MessageBeep(-1);
-
- // 1 second delay
- start = GetTickCount();
- while ( GetTickCount() < start + 1000 )
- ;
-
- // Beep
- MessageBeep(-1);
- break;
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CMyradioView::OnFilePlayme()
- {
- // TODO: Add your command handler code here
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- switch (dlg.m_VoiceStatus)
- {
- case 0:
- sp_PlaySnd (m_HelloSession,
- SP_START_OF_FILE,
- SP_END_OF_FILE );
- break;
-
- case 1:
- sp_PlaySnd (m_KennedySession,
- SP_START_OF_FILE,
- SP_END_OF_FILE );
- break;
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
- }
-