📄 setvolsys.~pas
字号:
unit SetVolSys;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IniFiles, StdCtrls, Buttons, ComCtrls, AMixer, PublicType;
type
TSetVolSystem = class(TForm)
Label1: TLabel;
CMBSelectCtrol: TComboBox;
TrackBar1: TTrackBar;
GroupBox1: TGroupBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ListBox1: TListBox;
ListBox2: TListBox;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Label2: TLabel;
ComboBox2: TComboBox;
Mixer: TAudioMixer;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure MixerControlChange(Sender: TObject; MixerH, ID: Integer);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure CMBSelectCtrolChange(Sender: TObject);
private
{ Private declarations }
Vol: Array[0..2] of Integer;
public
{ Public declarations }
end;
var
SetVolSystem: TSetVolSystem;
implementation
{$R *.dfm}
const
PText = '------>';
procedure TSetVolSystem.FormCreate(Sender: TObject);
var
i: Integer;
begin
if Self.Mixer.MixerCount>0 then
begin
Self.Vol[0] := ReadInteger('SetVolume', 'MainVolume');
Self.Vol[1] := ReadInteger('SetVolume', 'WaveVolume');
Self.Vol[2] := ReadInteger('SetVolume', 'LineVolume');
for i := 0 to Self.Mixer.Destinations.Count - 1 do
Self.ComboBox2.Items.Add (Mixer.Destinations[i].Data.szName);
if Self.ComboBox2.Items.Count > 0 then
begin
Self.ComboBox2.ItemIndex := ReadInteger('SetVolume', 'VolumeCtrl') + 1;
Self.ComboBox2Change(Self.ComboBox2);
Self.ListBox2.Items[0] := Self.CMBSelectCtrol.Items[0] + PText +
Self.ComboBox2.Items[Self.ComboBox2.ItemIndex];
for i := 1 to 2 do
Self.ListBox2.Items[i] := Self.CMBSelectCtrol.Items[i] + PText +
Self.ListBox1.Items[Self.Vol[i] + 1];
end;
end
else
begin
Self.ComboBox2.Items.Clear;
Self.ComboBox2.Enabled := FALSE;
Self.TrackBar1.Position := 0;
Self.TrackBar1.Enabled := FALSE;
Self.CheckBox1.Checked := FALSE;
Self.CheckBox1.Enabled := FALSE;
MessageDlg ('找不到音频设备 !', mtError, [mbOK], 0);
end;
case GetWinVersion of
WIN_32_S:
begin
Self.Font.Size := 10;
end;
WIN_95:
begin
Self.Font.Size := 10;
end;
WIN_NT:
begin
end;
end;//end GetWinVersion
end;
procedure TSetVolSystem.ComboBox2Change(Sender: TObject);
var
i: Integer;
begin
Self.ListBox1.Items.Clear;
Self.ListBox1.Items.Add(Self.Mixer.Destinations[Self.ComboBox2.ItemIndex].Data.szName);
For i := 0 to Self.Mixer.Destinations[Self.ComboBox2.ItemIndex].Connections.Count - 1 do
Self.ListBox1.Items.Add(Self.Mixer.Destinations[Self.ComboBox2.ItemIndex].Connections[i].Data.szName);
If Self.ListBox1.Items.Count > 0 then
begin
Self.CMBSelectCtrolChange(Self.CMBSelectCtrol);
Self.ListBox1Click(Self.ListBox1);
end;
end;
procedure TSetVolSystem.ListBox1Click(Sender: TObject);
var
L, R, M: Integer;
VD, MD: Boolean;
Stereo: Boolean;
begin
Self.Mixer.GetMute(Self.ComboBox2.ItemIndex, Self.ListBox1.ItemIndex - 1, MD);
Self.Mixer.GetVolume(Self.ComboBox2.ItemIndex, Self.ListBox1.ItemIndex - 1, L, R, M, Stereo, VD, MD);
Self.TrackBar1.Enabled := L <> -1;
if Self.TrackBar1.Enabled then
Self.TrackBar1.Position := L;
Self.CheckBox1.Enabled := M <> -1;
if Self.CheckBox1.Enabled then
Self.CheckBox1.Checked := M <> 0;
Self.SpeedButton3.Enabled := (Self.ListBox1.ItemIndex > 0) AND
(Self.ListBox1.Items[Self.ListBox1.ItemIndex] <> '') AND
(Self.CMBSelectCtrol.ItemIndex > 0);
end;
procedure TSetVolSystem.BitBtn1Click(Sender: TObject);
begin
WriteInteger('SetVolume', 'VolumeCtrl', Self.ComboBox2.ItemIndex - 1);
WriteInteger('SetVolume', 'MainVolume', Self.Vol[0]);
WriteInteger('SetVolume', 'WaveVolume', Self.Vol[1]);
WriteInteger('SetVolume', 'LineVolume', Self.Vol[2]);
Self.Close;
end;
procedure TSetVolSystem.BitBtn2Click(Sender: TObject);
begin
Self.Close;
end;
procedure TSetVolSystem.TrackBar1Change(Sender: TObject);
begin
Self.Mixer.SetVolume(Self.ComboBox2.ItemIndex, Self.ListBox1.ItemIndex - 1,
Self.TrackBar1.Position, -1, Integer(Self.CheckBox1.Checked));
end;
procedure TSetVolSystem.MixerControlChange(Sender: TObject; MixerH,
ID: Integer);
begin
Self.ListBox1Click(Self.ListBox1);
end;
procedure TSetVolSystem.SpeedButton1Click(Sender: TObject);
var
i: Integer;
begin
for i := 1 to 2 do
begin
Self.Vol[i] := 0;
Self.ListBox2.Items[i] := '';
end;
Self.SpeedButton2.Enabled := False;
end;
procedure TSetVolSystem.SpeedButton2Click(Sender: TObject);
begin
if Self.ListBox2.ItemIndex < 0 then
Exit;
Self.ListBox2.Items[Self.ListBox2.ItemIndex] := '';
Self.Vol[Self.ListBox2.ItemIndex] := 0;
end;
procedure TSetVolSystem.ListBox2Click(Sender: TObject);
begin
Self.SpeedButton2.Enabled := (Self.ListBox2.ItemIndex > 0) AND
(Self.ListBox2.Items[Self.ListBox2.ItemIndex] <> '');
end;
procedure TSetVolSystem.SpeedButton3Click(Sender: TObject);
var
i: Integer;
begin
i := Self.CMBSelectCtrol.ItemIndex;
if i <= 0 then
Exit;
Self.ListBox2.Items[i] := Self.CMBSelectCtrol.Items[i] + PText +
Self.ListBox1.Items[Self.ListBox1.ItemIndex];
if Self.ListBox1.ItemIndex > 0 then
Self.Vol[i] := Self.ListBox1.ItemIndex - 1
else
Self.Vol[i] := 0;
end;
procedure TSetVolSystem.CMBSelectCtrolChange(Sender: TObject);
begin
Self.SpeedButton3.Enabled := (Self.ListBox1.ItemIndex > 0) AND
(Self.ListBox1.Items[Self.ListBox1.ItemIndex] <> '') AND
(Self.CMBSelectCtrol.ItemIndex > 0);
if (Self.CMBSelectCtrol.ItemIndex > 0) AND
((Self.Vol[Self.CMBSelectCtrol.ItemIndex] + 1) < Self.ListBox1.Items.Count) then
Self.ListBox1.ItemIndex := Self.Vol[Self.CMBSelectCtrol.ItemIndex] + 1
else
Self.ListBox1.ItemIndex := 0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -