home *** CD-ROM | disk | FTP | other *** search
- // dancevw.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "dance.h"
- #include "dancevw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CDanceView
-
- IMPLEMENT_DYNCREATE(CDanceView, CFormView)
-
- CDanceView::CDanceView()
- : CFormView(CDanceView::IDD)
- {
- //{{AFX_DATA_INIT(CDanceView)
- m_pc = NULL;
- m_MultiTask = FALSE;
- //}}AFX_DATA_INIT
- }
-
- CDanceView::~CDanceView()
- {
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Delete the 4 bitmaps.
- for (int i=0; i<4; i++)
- delete m_pB[i];
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CDanceView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDanceView)
- DDX_VBControl(pDX, IDC_TEGOMM1, m_pc);
- DDX_Check(pDX, IDC_MULTITASK, m_MultiTask);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CDanceView, CFormView)
- //{{AFX_MSG_MAP(CDanceView)
- ON_BN_CLICKED(IDC_START_BUTTON, OnStartButton)
- ON_BN_CLICKED(IDC_STOP_BUTTON, OnStopButton)
- ON_VBXEVENT(VBN_DONE, IDC_TEGOMM1, OnDoneTegomm1)
- ON_VBXEVENT(VBN_STATUSUPDATE, IDC_TEGOMM1, OnStatusupdateTegomm1)
- ON_BN_CLICKED(IDC_MULTITASK, OnMultitask)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CDanceView message handlers
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- void CDanceView::OnInitialUpdate()
- {
-
- // Call the base class function.
- CFormView::OnInitialUpdate();
-
- // Set the DeviceType property for playback through the PC speaker.
- m_pc->SetStrProperty("DeviceType","PCSpeaker");
-
- // Disable the timer of the multimedia control.
- m_pc->SetNumProperty("UpdateInterval",0);
-
- // Set the FileName property.
- m_pc->SetStrProperty("FileName","\\VCPROG\\WAV\\BOURB2M3.WAV");
-
- // Make the multimedia control invisible.
- m_pc->SetNumProperty("Visible", FALSE);
-
- // Issue an Open command to the multimedia control.
- m_pc->SetStrProperty("Command","Open");
-
- // Was the sound file opened successfully?
- if ( m_pc->GetNumProperty("Error") != 0 )
- MessageBox("Cannot open the file "+m_pc->GetStrProperty("FileName"), "Error", MB_ICONEXCLAMATION);
-
- // 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 CDanceView::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 (pMemDC) into the screen DC (pDC).
- pDC->BitBlt(100,10,500,500,pMemDC,0,0,SRCCOPY);
-
- // Delete the memory DC.
- delete pMemDC;
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- void CDanceView::OnStartButton()
- {
- // TODO: Add your control notification handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Disable the Start push button.
- GetDlgItem(IDC_START_BUTTON)->EnableWindow(FALSE);
-
- // Initialize the current frame number to 0.
- m_CurrentFrame = 0;
-
- // Rewind the multimedia control.
- m_pc->SetStrProperty("Command","Prev");
-
-
- // Set the interval of the multimedia control timer.
- m_pc->SetNumProperty("UpdateInterval",400);
-
- // Start playing.
- m_pc->SetStrProperty("Command","Play");
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
-
- void CDanceView::OnStopButton()
- {
- // TODO: Add your control notification handler code here
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Stop the playback.
- m_pc->SetStrProperty("Command","Stop");
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
-
- void CDanceView::OnDoneTegomm1(UINT, int, CWnd*, LPVOID)
- {
- // TODO: Add your VBX event notification handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Disable the multimedia control timer.
- m_pc->SetNumProperty("UpdateInterval",0);
-
- // If in multitasking mode and position is end of file, restart playback.
- if (m_MultiTask==TRUE && m_pc->GetNumProperty("Position")==m_pc->GetNumProperty("Length"))
- {
- // Restart the playback.
- OnStartButton();
- }
- else
- {
- // Enable the Start push button.
- GetDlgItem(IDC_START_BUTTON)->EnableWindow(TRUE);
-
- // Display the first frame of the show (i.e. trigger a call to the OnDraw() function).
- Invalidate();
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
-
- void CDanceView::OnStatusupdateTegomm1(UINT, int, CWnd*, LPVOID)
- {
- // TODO: Add your VBX event notification handler code here
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Increment the current frame number.
- m_CurrentFrame++;
-
- // Was the last frame of the dance displayed?
- if (m_CurrentFrame==4)
- m_CurrentFrame=1;
-
- // 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 (pMemDC) into the screen DC (dc).
- dc.BitBlt(100,10,500,500,pMemDC,0,0,SRCCOPY);
-
- // Delete the memory DC.
- delete pMemDC;
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CDanceView::OnMultitask()
- {
- // TODO: Add your control notification handler code here
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Update the variable of the Multitasking check box (m_MultiTask).
- UpdateData(TRUE);
-
- // Enable multi-tasking?
- if (m_MultiTask==TRUE)
- {
- m_pc->SetNumProperty("pcMouseEnabled", TRUE);
- m_pc->SetNumProperty("pcTaskInterval",400);
- }
- else
- {
- m_pc->SetNumProperty("pcMouseEnabled", FALSE);
- m_pc->SetNumProperty("pcTaskInterval",0);
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-