【VC开源代码栏目提醒】:本文主要为网学会员提供MIXERPEAKMETER.CPP,希望对需要MIXERPEAKMETER.CPP网友有所帮助,学习一下!
//=============================================================================
// Copyright Langis Pitre 1998
// You may do whatever you want with this code, as long as you include this
// copyright notice in your implementation files.
//
// If you wish to add new classes to this collection, feel free to do so.
// But please send me your code so that I can update the collection.
//
// Comments and bug reports: lpitre@sympatico.ca
//
//=============================================================================
//=============================================================================
// CMixerPeakMeter
//
// Since this class is derived from CStatic, it allows the user to associate
// a static resource with a mixer peak meter control. All messages are handled
// internally through message reflection.
//
// This class uses a timer to check for line activity.
//
// How to use:
//
// 1) create a static resource (specify a resource ID other than IDC_STATIC)
// You can give it the Sunken style if you wish.
// 2) declare a variable of type CMixerPeakMeter in your CDialog-derived
// class declaration
// 3) In your OnInitDialog, subclass the CMixerPeakMeter object to associate it
// with the resource (or use DDE with a variable of type CMixerPeakMeter)
// 4) In your OnInitDialog, call the Init() member funcion.
//
// The peak meter works like the CProgressCtrl, except that it is vertical.
// It displays the audio level of the line it is associated with.
//
//=============================================================================
//=============================================================================
//=============================================================================
#include "stdafx.h"
#include "MixerPeakMeter.h"
#include "MemDC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMixerPeakMeter
//mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
// Name : CMixerPeakMeter
//
// Descr. :
//
// Arg : COLORREF background :
//-----------------------------------------------------------------------------
CMixerPeakMeter::CMixerPeakMeter(COLORREF background ) : CMixerBase()
{
m_timer = 0;
m_Bkgnd = background;
m_Value = NULL;
}
//mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
// Name : ~CMixerPeakMeter
//
// Descr. :
//
//-----------------------------------------------------------------------------
CMixerPeakMeter::~CMixerPeakMeter()
{
if( m_timer )
KillTimer( m_timer );
}
BEGIN_MESSAGE_MAP( CMixerPeakMeter, CStatic )
//{{AFX_MSG_MAP(CMixerPeakMeter)
ON_WM_PAINT()
ON_WM_DESTROY()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
// Name : Init
//
// Descr. : Initializes the mixer control.
// Init queries the mixer device for the specified mixer control type,
// which is always MIXERCONTROL_CONTROLTYPE_PEAKMETER in this case.
// If such a control is found, its current value is queried, and used
// to initialize the windows control.
// - If the call to CMixerBase::Init() is succesfull, m_Value is set to
// the address of the memory allocated by CMixerBase.
//
// Return : int 0 if failed, 1 otherwise
//
// Arg : DWORD DstType : see definition of CMixerBase::Init() for a description
// Arg : DWORD SrcType : see definition of CMixerBase::Init() for a description
//-----------------------------------------------------------------------------
int CMixerPeakMeter::Init( DWORD DstType, DWORD SrcType )
{
if ( m_hWnd == NULL )
{
PrintMessage( "CMixerFader::Init", "No Window attached. Did you create or subclass one?" );
return 0;
}
EnableWindow( FALSE );
if( CMixerBase::Init( DstType, SrcType, MIXERCONTROL_CONTROLTYPE_PEAKMETER, GetSafeHwnd() ) == 0 )
return 0;
m_Value = (MIXERCONTROLDETAILS_SIGNED*)GetValuePtr();
if( GetMixerControlValue() )
{
EnableWindow( TRUE );
if( m_timer == 0 )
{
m_timer = SetTimer( 345, 100, NULL );
}
}
return 1;
}
//mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
// Name : OnPaint
//
// Descr. :
//
// Return : void
//---------------------------------------