home *** CD-ROM | disk | FTP | other *** search
- // kennevw.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "kennedy.h"
- #include "kennevw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CKennedyView
-
- IMPLEMENT_DYNCREATE(CKennedyView, CFormView)
-
- CKennedyView::CKennedyView()
- : CFormView(CKennedyView::IDD)
- {
- //{{AFX_DATA_INIT(CKennedyView)
- m_wav = NULL;
- //}}AFX_DATA_INIT
- }
-
- CKennedyView::~CKennedyView()
- {
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Delete the 4 bitmaps.
- for (int i=0; i<4; i++)
- delete m_pB[i];
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
-
- }
-
- void CKennedyView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CKennedyView)
- DDX_VBControl(pDX, IDC_TEGOMM1, m_wav);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CKennedyView, CFormView)
- //{{AFX_MSG_MAP(CKennedyView)
- ON_BN_CLICKED(IDC_START_BUTTON, OnStartButton)
- ON_VBXEVENT(VBN_STATUSUPDATE, IDC_TEGOMM1, OnStatusupdateTegomm1)
- ON_VBXEVENT(VBN_DONE, IDC_TEGOMM1, OnDoneTegomm1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CKennedyView message handlers
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- void CKennedyView::OnInitialUpdate()
- {
-
- // Call the base class function.
- CFormView::OnInitialUpdate();
-
- // Set the DeviceType property for playback of WAV files.
- m_wav->SetStrProperty("DeviceType","WaveAudio");
-
- // Disable the timer of the multimedia control.
- m_wav->SetNumProperty("UpdateInterval",0);
-
- // Set the FileName property.
- m_wav->SetStrProperty("FileName",
- "\\VCPROG\\WAV\\8KENNED3.WAV");
-
- // Make the multimedia control invisible.
- m_wav->SetNumProperty("Visible", FALSE);
-
- // Issue an Open command to the multimedia control.
- m_wav->SetStrProperty("Command","Open");
-
- // Load IDB_BITMAP1
- m_pB[0] = new CBitmap;
- m_pB[0]->LoadBitmap(IDB_BITMAP1);
-
- // Load IDB_BITMAP2
- m_pB[1] = new CBitmap;
- m_pB[1]->LoadBitmap(IDB_BITMAP2);
-
- // Load IDB_BITMAP3
- m_pB[2] = new CBitmap;
- m_pB[2]->LoadBitmap(IDB_BITMAP3);
-
- // Load IDB_BITMAP4
- m_pB[3] = new CBitmap;
- m_pB[3]->LoadBitmap(IDB_BITMAP4);
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
-
- ///////////////////////
- // MY CODE STARTS HERE
- ///////////////////////
-
- void CKennedyView::OnDraw(CDC* pDC)
- {
-
- // Create a memory DC.
- CDC* pMemDC = new CDC;
- pMemDC->CreateCompatibleDC(pDC);
-
- // Select the bitmap into the memory DC.
- pMemDC->SelectObject( m_pB[0] );
-
- // Copy the bitmap from the memory DC into the screen DC.
- pDC->BitBlt(90,10,500,500,pMemDC,0,0,SRCCOPY);
-
- // Delete the memory DC.
- delete pMemDC;
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- void CKennedyView::OnStartButton()
- {
- // TODO: Add your control notification handler code here
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Disable the Start button.
- GetDlgItem(IDC_START_BUTTON)->EnableWindow(FALSE);
-
- // Initialize the current frame number to 0.
- m_CurrentFrame = 0;
-
- // Rewind the multimedia control.
- m_wav->SetStrProperty("Command","Prev");
-
- // Start playing the WAV file.
- m_wav->SetStrProperty("Command","Play");
-
- // Set the interval of the multimedia control timer.
- m_wav->SetNumProperty("UpdateInterval",350);
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
-
- }
-
- void CKennedyView::OnStatusupdateTegomm1(UINT, int, CWnd*, LPVOID)
- {
- // TODO: Add your VBX event notification handler code here
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Get the current position.
- long position = m_wav->GetNumProperty("Position");
-
- // Set the frame number in accordance with the current
- // playback position.
- if (position<3000)
- m_CurrentFrame = 1;
- if (position>3000 && position<7000)
- m_CurrentFrame = 2;
- if (position>7000)
- m_CurrentFrame = 3;
-
- // Get a DC for the screen.
- CClientDC dc(this);
-
- // Create a memory DC.
- CDC* pMemDC = new CDC;
- pMemDC->CreateCompatibleDC(&dc);
-
- // Select the bitmap into the memory DC.
- pMemDC->SelectObject( m_pB[m_CurrentFrame] );
-
- // Copy the bitmap from the memory DC into the screen DC.
- dc.BitBlt(90,10,500,500,pMemDC,0,0,SRCCOPY);
-
- // Delete the memory DC.
- delete pMemDC;
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CKennedyView::OnDoneTegomm1(UINT, int, CWnd*, LPVOID)
- {
- // TODO: Add your VBX event notification handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Disable the multimedia control timer.
- m_wav->SetNumProperty("UpdateInterval",0);
-
- // Enable the Start button.
- GetDlgItem(IDC_START_BUTTON)->EnableWindow(TRUE);
-
- // Trigger a call to the OnDraw() function.
- Invalidate();
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-