www.pudn.com > d4psp31.zip > fmTrackProperties.pas, change:1997-10-22,size:3143b


unit fmTrackProperties; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
  ComCtrls, StdCtrls, Buttons, cmpInstrument, ExtCtrls; 
 
type 
  TTrackPropertiesForm = class(TForm) 
    btnOk: TBitBtn; 
    btnCancel: TBitBtn; 
    PageControl1: TPageControl; 
    pgGeneral: TTabSheet; 
    pgPatchDetails: TTabSheet; 
    Label1: TLabel; 
    edTitle: TEdit; 
    Label2: TLabel; 
    edChannel: TEdit; 
    udChannel: TUpDown; 
    btnHelp: TBitBtn; 
    Label3: TLabel; 
    cbPort: TComboBox; 
    Label4: TLabel; 
    edBank: TEdit; 
    udBank: TUpDown; 
    Label5: TLabel; 
    edPatch: TEdit; 
    udPatch: TUpDown; 
    Label6: TLabel; 
    cbInstrument: TComboBox; 
    Label7: TLabel; 
    Panel1: TPanel; 
    stComment: TLabel; 
    procedure FormShow(Sender: TObject); 
    procedure cbPortChange(Sender: TObject); 
    procedure edBankChange(Sender: TObject); 
    procedure edPatchChange(Sender: TObject); 
    procedure cbInstrumentChange(Sender: TObject); 
  private 
    procedure RefreshPatchList; 
    procedure SelectPatch; 
    { Private declarations } 
  public 
    Instrument : TInstrument; 
    { Public declarations } 
  end; 
 
var 
  TrackPropertiesForm: TTrackPropertiesForm; 
 
implementation 
 
uses fmMainForm; 
 
{$R *.DFM} 
 
procedure TTrackPropertiesForm.FormShow(Sender: TObject); 
begin 
  Caption := Format ('Track Properties - Track %d', [MainForm.CurrentTrackNo]); 
  RefreshPatchList; 
  SelectPatch 
end; 
 
procedure TTrackPropertiesForm.RefreshPatchList; 
var i : Integer; 
begin 
  cbInstrument.items.Clear; 
  if Assigned (Instrument) then 
    for i := 0 to Instrument.ComponentCount - 1 do 
      cbInstrument.Items.Add (TPatch (Instrument.Components [i]).PatchName); 
end; 
 
procedure TTrackPropertiesForm.SelectPatch; 
var i : Integer; 
begin 
  if Assigned (Instrument) then 
  begin 
    try 
      for i := 0 to Instrument.ComponentCount - 1 do 
        with TPatch(Instrument.Components [i]) do 
          if (edBank.Text <> '') and (edPatch.Text <> '') and (BankNo = StrToInt (edBank.Text)) and (PatchNo = StrToInt (edPatch.Text)) then 
          begin 
            cbInstrument.ItemIndex := i; 
            stComment.Caption := Comment; 
            Exit 
          end; 
    except 
    end; 
 
  end; 
  cbInstrument.ItemIndex := -1; 
  stComment.Caption := '' 
end; 
 
procedure TTrackPropertiesForm.cbPortChange(Sender: TObject); 
begin 
  Instrument := MainForm.GetOutputPortInstrument (cbPort.ItemIndex); 
  RefreshPatchList; 
  SelectPatch 
end; 
 
procedure TTrackPropertiesForm.edBankChange(Sender: TObject); 
begin 
  SelectPatch; 
end; 
 
procedure TTrackPropertiesForm.edPatchChange(Sender: TObject); 
begin 
  SelectPatch 
end; 
 
procedure TTrackPropertiesForm.cbInstrumentChange(Sender: TObject); 
var 
  item : Integer; 
  patch : TPatch; 
begin 
  item := cbInstrument.ItemIndex; 
  if (item > -1) and (item < Instrument.ComponentCount) then 
  begin 
    patch := TPatch (Instrument.Components [item]); 
    edPatch.Text := IntToStr (patch.PatchNo); 
    edBank.Text := IntToStr (patch.BankNo) 
  end 
 
end; 
 
end.