home *** CD-ROM | disk | FTP | other *** search
- // mykeyvw.cpp : implementation of the CMykeyView class
- //
-
- #include "stdafx.h"
- #include "mykey.h"
-
- #include "mykeydoc.h"
- #include "mykeyvw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMykeyView
-
- IMPLEMENT_DYNCREATE(CMykeyView, CView)
-
- BEGIN_MESSAGE_MAP(CMykeyView, CView)
- //{{AFX_MSG_MAP(CMykeyView)
- ON_WM_KEYDOWN()
- ON_WM_CHAR()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMykeyView construction/destruction
-
- CMykeyView::CMykeyView()
- {
- // TODO: add construction code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- char FileToOpen[255];
-
-
- // Open the WAV session
- strcpy ( FileToOpen, "\\vcProg\\WAV\\Numbers.WAV" );
- m_NumbersSession = sp_OpenSession ( FileToOpen );
-
-
- // If WAV session can not be opened, display message box.
- if ( m_NumbersSession < 0 )
- {
- CString Message, Caption;
- Message = "Can't open the file: ";
- Message = Message + FileToOpen;
- Caption = "Error";
- MessageBox ( Message, Caption );
- }
-
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
-
- }
-
- CMykeyView::~CMykeyView()
- {
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- sp_CloseSession ( m_NumbersSession );
-
- ////////////////////,
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMykeyView drawing
-
- void CMykeyView::OnDraw(CDC* pDC)
- {
- CMykeyDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMykeyView diagnostics
-
- #ifdef _DEBUG
- void CMykeyView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CMykeyView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CMykeyDoc* CMykeyView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMykeyDoc)));
- return (CMykeyDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMykeyView message handlers
-
- void CMykeyView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- switch (nChar)
- {
-
- case VK_F1:
-
- if ( GetKeyState(VK_CAPITAL) & 0x0001 )
- {
- MessageBox ("You pressed F1. Caps Lock = ON");
- }
- else
- {
- MessageBox ("You pressed F1. Caps Lock = OFF");
- }
- break;
-
- case VK_LEFT:
-
- if ( GetKeyState(VK_CAPITAL) & 0x0001 )
- {
- MessageBox ("You pressed the Left arrow. Caps Lock = ON");
- }
- else
- {
- MessageBox ("You pressed the Left arrow. Caps Lock = OFF");
- }
- break;
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
-
- CView::OnKeyDown(nChar, nRepCnt, nFlags);
- }
-
- void CMykeyView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- if (nChar<32)
- {
- MessageBeep(-1);
- }
- else
- {
- CClientDC dc (this);
-
- dc.TextOut (10, 10, " ");
- dc.TextOut (10, 10, nChar);
- }
-
-
- switch (nChar)
- {
-
- case '0':
- sp_PlaySnd( m_NumbersSession,
- 1667,
- 8525 );
- break;
-
- case '1':
- sp_PlaySnd( m_NumbersSession,
- 10100,
- 16754 );
- break;
-
- case '2':
- sp_PlaySnd( m_NumbersSession,
- 20673,
- 26942 );
- break;
-
- case '3':
- sp_PlaySnd( m_NumbersSession,
- 30270,
- 38500 );
- break;
-
- case '4':
- sp_PlaySnd( m_NumbersSession,
- 42030,
- 51830 );
- break;
-
- case '5':
- sp_PlaySnd( m_NumbersSession,
- 53390,
- 61000 );
- break;
-
-
- case '6':
- sp_PlaySnd( m_NumbersSession,
- 64360,
- 72200 );
- break;
-
- case '7':
- sp_PlaySnd( m_NumbersSession,
- 75530,
- 85720 );
- break;
-
- case '8':
- sp_PlaySnd( m_NumbersSession,
- 87680,
- 93950 );
- break;
-
- case '9':
- sp_PlaySnd( m_NumbersSession,
- 98060,
- 106492 );
- break;
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- CView::OnChar(nChar, nRepCnt, nFlags);
- }
-