www.pudn.com > d4psp31.zip > fmProgramProperties.pas, change:1998-11-03,size:4594b


unit fmProgramProperties; 
 
interface 
 
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ComCtrls, ExtCtrls, ImgList; 
 
type 
  TProgramProperties = class(TForm) 
    Panel1: TPanel; 
    Panel2: TPanel; 
    PageControl1: TPageControl; 
    Preferences: TTabSheet; 
    MIDIOut: TTabSheet; 
    MidiInput: TTabSheet; 
    btnOk: TBitBtn; 
    btnCancel: TBitBtn; 
    cbShowHints: TCheckBox; 
    cbInitialTracksheet: TCheckBox; 
    cbAutoSynchronize: TCheckBox; 
    imgsMidiInput: TImageList; 
    GroupBox1: TGroupBox; 
    GroupBox2: TGroupBox; 
    lvUnselectedPorts: TListView; 
    btnAddMidiPort: TBitBtn; 
    btnRemoveMidiPort: TBitBtn; 
    lvSelectedPorts: TListView; 
    gbOutputPorts: TGroupBox; 
    btnInstruments: TBitBtn; 
    imgsMidiOutput: TImageList; 
    cbDefaultOutput: TCheckBox; 
    Label1: TLabel; 
    edDragNoteVolume: TEdit; 
    udDragNoteVolume: TUpDown; 
    cbBoostPlaybackPriority: TCheckBox; 
    elvOutputPorts: TListView; 
    procedure lvUnselectedPortsChange(Sender: TObject; Item: TListItem; 
      Change: TItemChange); 
    procedure lvSelectedPortsChange(Sender: TObject; Item: TListItem; 
      Change: TItemChange); 
    procedure FormShow(Sender: TObject); 
    procedure btnAddMidiPortClick(Sender: TObject); 
    procedure btnRemoveMidiPortClick(Sender: TObject); 
    procedure btnInstrumentsClick(Sender: TObject); 
    procedure cbDefaultOutputClick(Sender: TObject); 
    procedure elvOutputPortsChange(Sender: TObject; Item: TListItem; 
      Change: TItemChange); 
  private 
    { Private declarations } 
  public 
  	DefaultPortNo : Integer; 
    { Public declarations } 
  end; 
 
var 
  ProgramProperties: TProgramProperties; 
 
implementation 
 
{$R *.DFM} 
 
uses mmsystem, fmInstruments, fmMainForm; 
 
procedure TProgramProperties.lvUnselectedPortsChange(Sender: TObject; 
  Item: TListItem; Change: TItemChange); 
begin 
  btnAddMidiPort.Enabled := lvUnselectedPorts.Selected <> Nil; 
end; 
 
procedure TProgramProperties.lvSelectedPortsChange(Sender: TObject; 
  Item: TListItem; Change: TItemChange); 
begin 
  btnRemoveMidiPort.Enabled := lvSelectedPorts.Selected <> Nil; 
end; 
 
procedure TProgramProperties.FormShow(Sender: TObject); 
begin 
  PageControl1.ActivePage := Preferences; 
  btnAddMidiPort.Enabled := lvUnselectedPorts.Selected <> Nil; 
  btnRemoveMidiPort.Enabled := lvSelectedPorts.Selected <> Nil; 
  cbDefaultOutput.Enabled := False; 
  cbDefaultOutput.Visible := elvOutputPorts.Items.Count > 1; 
  btnInstruments.Enabled := False; 
end; 
 
procedure TProgramProperties.btnAddMidiPortClick(Sender: TObject); 
var 
  i : Integer; 
  item : TListItem; 
begin 
  i := 0; 
  with lvUnselectedPorts do 
    while i < items.Count do 
      if items [i].selected then 
      begin 
        item := lvSelectedPorts.Items.Add; 
        item.caption := items [i].caption; 
        items.Delete (i) 
      end 
      else Inc (i); 
end; 
 
procedure TProgramProperties.btnRemoveMidiPortClick(Sender: TObject); 
var 
  i : Integer; 
  item : TListItem; 
begin 
  i := 0; 
  with lvSelectedPorts do 
    while i < items.Count do 
      if items [i].selected then 
      begin 
        item := lvUnselectedPorts.Items.Add; 
        item.caption := items [i].caption; 
        items.Delete (i) 
      end 
      else Inc (i); 
end; 
 
procedure TProgramProperties.btnInstrumentsClick(Sender: TObject); 
var 
  dialog : TInstrumentsForm; 
  portNo : Integer; 
begin 
  if Assigned (elvOutputPorts.Selected) then 
  begin 
    portNo := elvOutputPorts.Selected.Index; 
    dialog := TInstrumentsForm.Create (self); 
    try 
      dialog.FileName := MainForm.GetOutputPortInstrumentName (portNo); 
      if dialog.ShowModal = mrOk then 
      begin 
        elvOutputPorts.Selected.SubItems [1] := ExtractInstrumentName (dialog.FileName); 
        MainForm.SetOutputPortInstrument (portNo, dialog.FileName); 
      end 
    finally 
      dialog.Free 
    end 
  end 
end; 
 
procedure TProgramProperties.cbDefaultOutputClick(Sender: TObject); 
begin 
  if cbDefaultOutput.Focused and Assigned (elvOutputPorts.Selected) then 
    if cbDefaultOutput.Checked then 
      DefaultPortNo := elvOutputPorts.Selected.Index 
    else 
      DefaultPortNo := 0; 
end; 
 
procedure TProgramProperties.elvOutputPortsChange(Sender: TObject; 
  Item: TListItem; Change: TItemChange); 
begin 
  cbDefaultOutput.Checked := Item.Index = DefaultPortNo; 
  cbDefaultOutput.Enabled := Assigned (elvOutputPorts.Selected); 
  btnInstruments.Enabled := Assigned (elvOutputPorts.Selected); 
end; 
 
end.