Это можно организовать самому, приблизительно так
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
#include
HMIXER hmix;
MIXERCAPS mixcaps;
int VolumeID,volmin,volmax;
MIXERCONTROLDETAILS details;
MIXERCONTROL mixctrl;
MIXERCONTROLDETAILS_UNSIGNED valdets;
DWORD curvolume;
bool svEnable;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TSetVol *SetVol;
//---------------------------------------------------------------------------
__fastcall TSetVol::TSetVol(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// Change Volume (-)
void __fastcall TSetVol::SpeedButton1Click(TObject *Sender)
{
if(!svEnable) return;
VolBar->Position = VolBar->Position-(VolBar->Max-VolBar->Min)/10;
if(VolBar->Position < VolBar->Min) VolBar->Position = VolBar->Min;
details.cbStruct = sizeof(details);
details.dwControlID = VolumeID;
details.cChannels = 1;
details.cMultipleItems = 0;
details.cbDetails = sizeof(valdets);
details.paDetails = &valdets;
if(VolBar->Position> 4000)
valdets.dwValue = VolBar->Position;
else
valdets.dwValue = 0;
mixerSetControlDetails((HMIXEROBJ)hmix,&details,MIXER_SETCONTROLDETAILSF_VALUE);
}
//---------------------------------------------------------------------------
// Change Volume (+)
void __fastcall TSetVol::SpeedButton2Click(TObject *Sender)
{
if(!svEnable) return;
VolBar->Position = VolBar->Position+(VolBar->Max-VolBar->Min)/10;
if(VolBar->Position> VolBar->Max) VolBar->Position = VolBar->Max;
details.cbStruct = sizeof(details);
details.dwControlID = VolumeID;
details.cChannels = 1;
details.cMultipleItems = 0;
details.cbDetails = sizeof(valdets);
details.paDetails = &valdets;
if(VolBar->Position> 4000)
valdets.dwValue = VolBar->Position;
else
valdets.dwValue = 0;
mixerSetControlDetails((HMIXEROBJ)hmix,&details,MIXER_SETCONTROLDETAILSF_VALUE);
}
//---------------------------------------------------------------------------
void __fastcall TSetVol::FormDestroy(TObject *Sender)
{
if(!svEnable) return;
mixerClose(hmix);
}
//---------------------------------------------------------------------------
void __fastcall TSetVol::FormCreate(TObject *Sender)
{
unsigned int i;
MIXERLINE mixline;
MIXERLINECONTROLS mixlinectrl;
MIXERCONTROL mixctrl;
MMRESULT rc; // Return code.
rc = mixerOpen(&hmix,0,0,0,0);
if (MMSYSERR_NOERROR == rc) { ; } else ShowMessage("Error");
ZeroMemory(&mixline,sizeof(mixline));
mixerGetDevCaps(0,&mixcaps,sizeof(mixcaps));
for(i=0; i < mixcaps.cDestinations-1; i++)
{
mixline.dwDestination = i;
mixline.cbStruct = sizeof(mixline);
mixerGetLineInfo((HMIXEROBJ)hmix,&mixline,MIXER_GETLINEINFOF_DESTINATION);
if(mixline.dwComponentType==MIXERLINE_COMPONENTTYPE_DST_SPEAKERS) break;
}
if(mixline.dwComponentType!=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS)
{
ShowMessage("Error. Mixer is disabled !");
svEnable = false;
return;
}
else
svEnable = true;
ZeroMemory(&mixlinectrl, sizeof(mixlinectrl));
mixlinectrl.cbStruct = sizeof(mixlinectrl);
mixlinectrl.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mixlinectrl.dwLineID = mixline.dwLineID;
mixlinectrl.cControls = 2;
ZeroMemory(&mixctrl, sizeof(mixctrl));
mixlinectrl.cbmxctrl = sizeof(mixctrl);
mixctrl.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
mixlinectrl.pamxctrl = &mixctrl;
mixerGetLineControls((HMIXEROBJ)hmix,&mixlinectrl,MIXER_GETLINECONTROLSF_ONEBYTYPE);
VolumeID = mixctrl.dwControlID;
volmin = mixctrl.Bounds.dwMinimum;
volmax = mixctrl.Bounds.dwMaximum;
details.cbStruct = sizeof(details);
details.dwControlID = VolumeID;
details.cChannels = 1;
details.cMultipleItems =0;
details.cbDetails = sizeof(valdets);
details.paDetails = &valdets;
mixerGetControlDetails((HMIXEROBJ)hmix,&details,MIXER_GETCONTROLDETAILSF_VALUE);
curvolume = valdets.dwValue;
VolBar->Min = volmin;
VolBar->Max = volmax;
VolBar->Position = curvolume;
}
//------------------------------------------------------
Пример проекта к C++Builder 6 — здесь (4 Кб)
|