📄 multimediademomain.pas
字号:
Items.Clear;
for DeviceIndex := 0 to FMixer.DeviceCount - 1 do
begin
Device := FMixer.Devices[DeviceIndex];
DeviceNode := Items.AddChildObjectFirst(nil, Device.ProductName, Device);
for DestionationIndex := 0 to Device.DestinationCount - 1 do
begin
Destination := Device.Destinations[DestionationIndex];
DestionationNode := Items.AddChildObjectFirst(DeviceNode, Destination.Name, Destination);
for LineControlIndex := 0 to Destination.LineControlCount - 1 do
begin
LineControl := Destination.LineControls[LineControlIndex];
Items.AddChildObjectFirst(DestionationNode, LineControl.Name, LineControl);
end;
for SourceIndex := 0 to Destination.SourceCount - 1 do
begin
SourceLine := Destination.Sources[SourceIndex];
SourceNode := Items.AddChildObjectFirst(DestionationNode, SourceLine.Name, SourceLine);
for LineControlIndex := 0 to SourceLine.LineControlCount - 1 do
begin
LineControl := SourceLine.LineControls[LineControlIndex];
Items.AddChildObjectFirst(SourceNode, LineControl.Name, LineControl);
end;
end;
end;
end;
FullExpand;
if Items.Count > 0 then
begin
Selected := Items.GetFirstNode;
Selected.MakeVisible;
end;
finally
Items.EndUpdate;
Screen.Cursor := crDefault;
end;
end;
end;
function TMainForm.GetSelectedMixerTreeObject: TObject;
begin
if MixerTreeView.Selected <> nil then
Result := TObject(MixerTreeView.Selected.Data)
else
Result := nil;
end;
procedure TMainForm.SaveMixerToFile(const FileName: string);
var
List: TStringList;
I, D: Integer;
Node: TTreeNode;
C: Char;
begin
List := TStringList.Create;
MixerDetailListView.Items.BeginUpdate;
try
for I := 0 to MixerTreeView.Items.Count - 1 do
begin
Node := MixerTreeView.Items[I];
UpdateMixerDetails(TObject(Node.Data));
case Node.Level of
0: C := ' ';
1: C := '=';
2: C := '+';
3: C := '-';
else
C := '!';
end;
List.Add(Format('%*s%s %s', [Node.Level * 2, '', Node.Text, StringOfChar(C, 119 - Node.Level * 2 - Length(Node.Text))]));
with MixerDetailListView.Items do
for D := 0 to Count - 1 do
begin
List.Add(Format('%*s%s=%s', [Node.Level * 2, '', Item[D].Caption, Item[D].SubItems[0]]));
end;
List.Add('');
end;
List.SaveToFile(FileName);
Node := MixerTreeView.Selected;
if Assigned(Node) then
UpdateMixerDetails(TObject(Node.Data))
else
UpdateMixerDetails(nil);
finally
MixerDetailListView.Items.EndUpdate;
List.Free;
end;
end;
procedure TMainForm.UpdateMixerDetails(MixerObject: TObject);
procedure AddLine(const ItemName, Value: string);
begin
with MixerDetailListView.Items.Add do
begin
Caption := ItemName;
SubItems.Add(Value);
end;
end;
procedure BuildMixerDeviceDetails(Device: TJclMixerDevice);
begin
with Device do
begin
AddLine('Handle', IntToHex(Handle, 8));
AddLine('Mid', IntToHex(Capabilities.wMid, 4));
AddLine('Pid', IntToHex(Capabilities.wPid, 4));
with WordRec(LongRec(Capabilities.vDriverVersion).Lo) do
AddLine('Driver version', FormatVersionString(Hi, Lo));
AddLine('Support', IntToHex(Capabilities.fdwSupport, 8));
end;
end;
procedure BuildMixerLineDetails(Line: TJclMixerLine);
var
DisplayName: string;
begin
with Line do
begin
DisplayName := ComponentString;
if DisplayName = '' then
DisplayName := Format('(%.8x)', [LineInfo.dwComponentType]);
AddLine('Component type', Format('%s [%s]', [DisplayName, ComponentTypeConstToString(LineInfo.dwComponentType)]));
AddLine('ID', IntToHex(ID, 8));
AddLine('Channels', IntToStr(LineInfo.cChannels));
AddLine('Connections', IntToStr(LineInfo.cConnections));
AddLine('Target name', LineInfo.Target.szPname);
end;
end;
procedure BuildMixerDestinationDetails(Destination: TJclMixerDestination);
begin
BuildMixerLineDetails(Destination);
end;
procedure BuildMixerSourceDetails(Source: TJclMixerSource);
begin
BuildMixerLineDetails(Source);
end;
procedure BuildMixerLineControlDetails(LineControl: TJclMixerLineControl);
begin
with LineControl do
begin
AddLine('ID', IntToHex(ControlInfo.dwControlID, 8));
AddLine('Control type', Format('%.8x [%s]', [ControlInfo.dwControlType, ControlTypeConstToString(ControlInfo.dwControlType)]));
AddLine('Disabled', BooleanToStr(IsDisabled));
AddLine('List', BooleanToStr(IsList));
AddLine('Multiple', BooleanToStr(IsMultiple));
AddLine('Uniform', BooleanToStr(IsUniform));
AddLine('Multiple items', IntToHex(ControlInfo.cMultipleItems, 8));
if not IsMultiple then
AddLine('Uniform value', IntToHex(UniformValue, 8));
AddLine('Minimum', IntToHex(ControlInfo.Bounds.lMinimum, 8));
AddLine('Maximum', IntToHex(ControlInfo.Bounds.lMaximum, 8));
AddLine('Steps', IntToHex(ControlInfo.Metrics.cSteps, 8));
AddLine('Value', ValueString);
AddLine('List text', ListText.CommaText);
end;
end;
begin
with MixerDetailListView do
begin
Items.BeginUpdate;
try
Items.Clear;
if MixerObject is TJclMixerDevice then
BuildMixerDeviceDetails(TJclMixerDevice(MixerObject))
else
if MixerObject is TJclMixerDestination then
BuildMixerDestinationDetails(TJclMixerDestination(MixerObject))
else
if MixerObject is TJclMixerSource then
BuildMixerSourceDetails(TJclMixerSource(MixerObject))
else
if MixerObject is TJclMixerLineControl then
BuildMixerLineControlDetails(TJclMixerLineControl(MixerObject));
finally
Items.EndUpdate;
end;
end;
end;
procedure TMainForm.UpdateMixerControl(MixerHandle: HMIXER; ControlID: DWORD);
var
Control: TJclMixerLineControl;
begin
Control := FMixer.LineControlByID[MixerHandle, ControlID];
if Control <> nil then
begin
if Control = SelectedMixerTreeObject then
UpdateSelectedMixerInfo;
end;
end;
procedure TMainForm.UpdateMixerLine(MixerHandle: HMIXER; LineID: DWORD);
var
Line: TJclMixerLine;
begin
Line := FMixer.LineByID[MixerHandle, LineID];
if Line <> nil then
begin
if Line = SelectedMixerTreeObject then
UpdateSelectedMixerInfo;
if Line.LineInfo.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS then
UpdateMixerSpeakerControls;
end;
end;
procedure TMainForm.UpdateSelectedMixerInfo;
begin
UpdateMixerDetails(SelectedMixerTreeObject);
end;
procedure TMainForm.UpdateMixerSpeakerControls;
begin
SpeakersMuteCheckBox.Checked := FMixer.SpeakersMute;
end;
procedure TMainForm.MixerTreeViewCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
NodeObject: TObject;
begin
NodeObject := TObject(Node.Data);
if NodeObject is TJclMixerDevice then
Sender.Canvas.Font.Style := [fsBold]
else
if NodeObject is TJclMixerDestination then
begin
Sender.Canvas.Font.Style := [fsBold];
if not (cdsFocused in State) then
Sender.Canvas.Font.Color := clRed;
end
else
if NodeObject is TJclMixerSource then
begin
Sender.Canvas.Font.Style := [fsBold];
if not (cdsFocused in State) then
Sender.Canvas.Font.Color := clBlue;
end;
end;
procedure TMainForm.MixerTreeViewChange(Sender: TObject; Node: TTreeNode);
begin
UpdateMixerDetails(TObject(Node.Data));
end;
procedure TMainForm.SpeakersMuteCheckBoxClick(Sender: TObject);
begin
FMixer.SpeakersMute := SpeakersMuteCheckBox.Checked;
end;
procedure TMainForm.SaveMixerBtnClick(Sender: TObject);
begin
SaveDialog.FileName := 'Mixer.txt';
if SaveDialog.Execute then
SaveMixerToFile(SaveDialog.FileName);
end;
procedure TMainForm.WMMmMixmControlChange(var Message: TMessage);
begin
UpdateMixerControl(Message.WParam, Message.LParam);
end;
procedure TMainForm.WMMmMixmLineChange(var Message: TMessage);
begin
UpdateMixerLine(Message.WParam, Message.LParam);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -