📄 dlgsrc.cpp
字号:
// ----------------------------------------------------------------------------------
// OnComboSpeaker
// update speaker mask of dst
// ----------------------------------------------------------------------------------
void CDlgSrc::OnComboSpeaker()
{
//
// prepare
//
int nSpeaker = m_nSpeaker;
UpdateData(TRUE);
//
// make selection
//
m_dwChannelMask = ( DWORD )m_comboSpeaker.GetItemData(m_nSpeaker);
//
// validate selection
//
if(! ((CChildView*)m_pwndParent)->UpdateDialogs())
{
MessageBox("There is already a channel with that speaker config", "MultiChan : Error!", MB_ICONSTOP | MB_OK);
m_nSpeaker = nSpeaker;
UpdateData( FALSE );
}
}
// ----------------------------------------------------------------------------------
// OnPlay
// preview button
// ----------------------------------------------------------------------------------
void CDlgSrc::OnPlay()
{
MMRESULT mmRes = MMSYSERR_NOERROR;
//
// ensure validity
//
ASSERT( 0 == g_hwo );
ASSERT( m_fPlayable );
//
// first usage ?
//
if( 0 == m_lpwhdr )
{
m_lpwhdr = ( LPWAVEHDR )LocalAlloc( LPTR, sizeof( WAVEHDR ) );
if( 0 == m_lpwhdr )
{
MessageBox( "Insufficient memory for rendering !", "MultiChan : Error", MB_ICONEXCLAMATION | MB_OK );
return;
}
}
m_lpwhdr->dwBufferLength = m_cbData;
m_lpwhdr->lpData = (char*)m_pvData;
//
// using a callback mechanism to allow synch playback
//
mmRes = waveOutOpen( &g_hwo,
WAVE_MAPPER,
&m_wfx,
( DWORD_PTR )WavePlayFileCB,
( DWORD_PTR )this,
CALLBACK_FUNCTION
);
if( TrapMMError(mmRes, "waveOutOpen") )
{
mmRes = waveOutPrepareHeader( g_hwo, m_lpwhdr, sizeof(WAVEHDR) );
if( TrapMMError(mmRes, "waveOutPrepareHeader") )
{
//
// revert playable state
// disable any other dialog
//
WaveTogglePlayback( this, WAVE_TOGGLE_DISABLE );
//
// start singing
//
mmRes = waveOutWrite( g_hwo, m_lpwhdr, sizeof(WAVEHDR));
TrapMMError(mmRes, "waveOutWrite");
} // prepare header
} // open
} // CDlgSrc::OnPlay
// -------------------------------------------------------------------------------------
// OnStop
//
// -------------------------------------------------------------------------------------
inline
void
CDlgSrc::OnStop
()
{
MMRESULT mmRes = MMSYSERR_NOERROR;
//
// ensure validity
//
ASSERT( g_hwo );
ASSERT( !m_fPlayable );
//
// stop playback
//
mmRes = waveOutReset( g_hwo );
TrapMMError( mmRes, "waveOutReset" );
} // CDglSrc::OnStop
// ----------------------------------------------------------------------------------
// dummy implementations to prevent dlgs from disappearing when user hits enter or esc
// ----------------------------------------------------------------------------------
inline
void
CDlgSrc::OnOK
()
{
POSITION pos = g_listSources.Find(this, NULL);
g_listSources.RemoveAt(pos);
g_pChildView->UpdateDialogs();
delete this;
} // CDglSrc::OnOK
//
//
//
inline
void
CDlgSrc::OnCancel
()
{
POSITION pos = g_listSources.Find(this, NULL);
g_listSources.RemoveAt(pos);
g_pChildView->UpdateDialogs();
delete this;
} // CDglSrc::OnCancel
//
//
//
HBRUSH
CDlgSrc::OnCtlColor
(
CDC* pDC,
CWnd* pWnd,
UINT nCtlColor
)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if((nCtlColor == CTLCOLOR_STATIC))
{
if(pWnd->m_hWnd == m_cInput.m_hWnd)
{
pDC->SetTextColor(GetSysColor(COLOR_CAPTIONTEXT));
pDC->SetBkMode(TRANSPARENT); //BkColor(GetSysColor(COLOR_ACTIVECAPTION));
return GetSysColorBrush(COLOR_ACTIVECAPTION);
}
}
return hbr;
} // CDglSrc::OnCtlColor
//
//
//
void
CDlgSrc::OnLButtonDown
(
UINT nFlags,
CPoint point
)
{
RECT rcClient;
m_cInput.GetClientRect(&rcClient);
m_cInput.MapWindowPoints(this, &rcClient);
m_fDragging = PtInRect(&rcClient, point);
if(m_fDragging)
{
SetCapture();
m_fDragging = TRUE;
m_ptPosInCaption = point;
}
CDialog::OnLButtonDown(nFlags, point);
SetFocus();
SetWindowPos(&wndTop, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
} // CDglSrc::OnLButtonDown
//
//
//
void
CDlgSrc::OnLButtonUp
(
UINT nFlags,
CPoint point
)
{
m_fDragging = FALSE;
ReleaseCapture();
CDialog::OnLButtonUp(nFlags, point);
} // CDglSrc::OnLButtonUp
//
//
//
void
CDlgSrc::OnMouseMove
(
UINT nFlags,
CPoint point
)
{
RECT rcClientParent;
GetParent()->GetClientRect(&rcClientParent);
GetParent()->MapWindowPoints(this, &rcClientParent);
if(PtInRect(&rcClientParent, point))
{
if(m_fDragging)
{
CRect rcWindow;
CRect rcParent;
CPoint pt(point.x - m_ptPosInCaption.x, point.y - m_ptPosInCaption.y);
GetWindowRect(&rcWindow);
GetParent()->GetWindowRect(&rcParent);
rcWindow.OffsetRect(pt);
rcWindow -= rcParent.TopLeft();
SetWindowPos(NULL, rcWindow.left, rcWindow.top, 0,0, SWP_NOZORDER | SWP_NOSIZE);
}
}
else
{
ReleaseCapture();
m_fDragging = FALSE;
}
} // CDglSrc::OnMouseMove
//
//
//
BOOL
CDlgSrc::OnInitDialog
()
{
CDialog::OnInitDialog();
HICON hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CHECK));
m_butClose.SetIcon(hIcon);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
} // CDlgSrc::OnInitDialog
//
//
//
LRESULT
CDlgSrc::WindowProc
(
UINT nMessage,
WPARAM wParam,
LPARAM lParam
)
{
MMRESULT mmRes = MMSYSERR_NOERROR;
switch( nMessage )
{
case WM_START_PLAYBACK:
{
break;
}
case WM_STOP_PLAYBACK:
{
//
// revert playable state
//
WaveTogglePlayback( this, WAVE_TOGGLE_ALLOW );
//
// unprepare and release
//
mmRes = waveOutUnprepareHeader( g_hwo, m_lpwhdr, sizeof( WAVEHDR ) );
if( TrapMMError( mmRes, "waveOutUnprepareHeader" ) )
{
mmRes = waveOutClose( g_hwo );
TrapMMError( mmRes, "waveOutClose" );
g_hwo = 0;
}
break;
}
}
return( CDialog::WindowProc( nMessage, wParam, lParam ) );
} // CDlgSrc::WindowProc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -