www.pudn.com > EndpointDetection_Pitch.zip > Chords.cpp


// Chords.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Pitch.h" 
#include "PitchDlg.h" 
#include "Prompt.h" 
#include "Chords.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
extern int ChordX, ChordY, ChordWidth, ChordHeight; 
extern HWND myHWND; 
extern int currentDialog; 
 
int ChordTimerKey; 
int ChordWaitLength = 250; 
int ChordTimerWaitSwitch = 0; 
 
MSG ChordMessage;  
///////////////////////////////////////////////////////////////////////////// 
// CChords dialog 
 
 
CChords::CChords(CWnd* pParent /*=NULL*/) 
	: CDialog(CChords::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CChords) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CChords::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CChords) 
	DDX_Control(pDX, IDC_ChordsTitle, m_ChordsTitle); 
	DDX_Control(pDX, IDC_ChordsPlayNote, m_ChordsPlayNote); 
	DDX_Control(pDX, IDC_ChordsScore, m_ChordsScore); 
	DDX_Control(pDX, IDC_GetOutOfChords, m_GetOutOfChords); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CChords, CDialog) 
	//{{AFX_MSG_MAP(CChords) 
	ON_WM_DESTROY() 
	ON_WM_TIMER() 
	ON_WM_RBUTTONDOWN() 
	ON_WM_RBUTTONUP() 
	ON_BN_CLICKED(IDC_ChordsPlayNote, OnChordsPlayNote) 
	ON_BN_CLICKED(IDC_ChordsScore, OnChordsScore) 
	ON_BN_CLICKED(IDC_GetOutOfChords, OnGetOutOfChords) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_BN_CLICKED(IDC_ChordsTitle, OnChordsTitle) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CChords message handlers 
 
BEGIN_EVENTSINK_MAP(CChords, CDialog) 
    //{{AFX_EVENTSINK_MAP(CChords) 
	//}}AFX_EVENTSINK_MAP 
END_EVENTSINK_MAP() 
 
BOOL CChords::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// Set the Chord window to where it finished last time 
	MoveWindow(ChordX, ChordY, ChordWidth, ChordHeight, TRUE); 
	//m_MainLabel. 
	m_ChordsPlayNote.SetShade(SHS_METAL,8,30); 
	m_ChordsPlayNote.SetTextColor(PurpleColour); 
	m_ChordsPlayNote.SetFont("Signature",24,20); 
	m_ChordsScore.SetShade(SHS_METAL,8,30); 
	m_ChordsScore.SetTextColor(PurpleColour); 
	m_ChordsScore.SetFont("Signature",24,20); 
	m_GetOutOfChords.SetShade(SHS_SOFTBUMP,6,30); 
	m_GetOutOfChords.SetTextColor(RedColour); 
	m_GetOutOfChords.SetFont("Signature",24,20); 
 
	m_ChordsTitle.SetShade(SHS_METAL,8,30); 
	m_ChordsTitle.SetTextColor(PurpleColour); 
	m_ChordsTitle.SetFont("Signature",72,20); 
	m_ChordsTitle.SetWindowText("Chords"); 
 
	 
	UpdateData(FALSE); 
	currentDialog = ChordsDialog; 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CChords::OnDestroy()  
{ 
	CDialog::OnDestroy(); 
	 
	// Grab the screen location at end for the registry 
	CRect rect; 
	GetWindowRect(&rect); 
	CPoint TL; 
	TL = rect.TopLeft();  
	ChordX = TL.x;  ChordY = TL.y; 
	rect.NormalizeRect(); 
	ChordWidth = rect.Width(); ChordHeight = rect.Height(); 
	 
} 
 
void CChords::OnTimer(UINT nIDEvent)  
{ 
	ChordTimerWaitSwitch = 1; 
	 
	CDialog::OnTimer(nIDEvent); 
} 
 
void CChords::OnRButtonDown(UINT nFlags, CPoint point)  
{ 
	// Display the pop up menu section on right mouse button down 
	// Have to find out where our dialog is presently sitting 
CRect rect; 
CPoint TL;  
	int x; int y; 
	GetWindowRect(&rect); 
	TL = rect.TopLeft();  
	ChordX = TL.x;  ChordY = TL.y; 
	x = point.x + ChordX + 20; y = point.y + ChordY + 17; 
	CPitchDlg PopupTime;  
	PopupTime.ProcessPopupMenu(x,y);		 
	CDialog::OnRButtonDown(nFlags, point); 
} 
 
void CChords::OnRButtonUp(UINT nFlags, CPoint point)  
{ 
	// here 
	 
	CDialog::OnRButtonUp(nFlags, point); 
} 
 
void CChords::DoChordWait(int WaitTimeInMilliseconds) 
{ 
	ChordTimerWaitSwitch = 0; 
	ChordTimerKey = SetTimer(1, WaitTimeInMilliseconds, NULL);                           
	ASSERT(ChordTimerKey !=0); 
//  Wait until the timer changes ChordTimerWaitSwitch to non zero.  
//  The PeekMessage will allow the message through 
	while (ChordTimerWaitSwitch == 0)                                                   
		{if(::PeekMessage(&ChordMessage, NULL, 0, 0, PM_REMOVE))                    
			{                                                                     
			::TranslateMessage(&ChordMessage);                                         
			::DispatchMessage(&ChordMessage);                                          
			}  
        }; 
	KillTimer(ChordTimerKey);  
} 
 
void CChords::OnGetOutOfChords()  
{ 
		CDialog::OnOK();	 
} 
 
 
 
void CChords::OnChordsPlayNote()  
{ 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CChords::OnChordsScore()  
{ 
	// TODO: Add your control notification handler code here 
	 
} 
 
void CChords::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CChords::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
//		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
//HCURSOR CChords::OnQueryDragIcon() 
//{ 
//	return (HCURSOR) m_hIcon; 
//} 
 
void CChords::OnChordsTitle()  
{ 
	// TODO: Add your control notification handler code here 
	 
}