p align="left"> SetButtons; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.RandomizeButtonClick(Sender: TObject); var i,j: integer; begin Randomize; for i := 0 to TempPlayList.Count-1 do begin j := Random(TempPlayList.Count); TempPlayList.Move(i, j); PlayListBox.Items.Move(i, j); end; ListChanged := True; SetButtons; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.DragTimerExpired(Sender: TObject); Var Приложение А (продолжение) MousePos: TPoint; begin if DragTarget <> Nil then begin GetCursorPos(MousePos); MousePos := ScreenToClient(MousePos); with DragTarget do begin if (MousePos.X > Left) And (MousePos.X < Left + Width) then begin { scroll the listbox up } if (MousePos.Y < Top) And (TopIndex > 0) then TopIndex := TopIndex - 1 else { scroll the listbox down } if (MousePos.Y > Top + Height) And (TopIndex < Items.Count - (Height div ItemHeight)) then TopIndex := TopIndex + 1; end; end; end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.DrawIndexPtr(oldIndex, newIndex: integer); const Offset: integer = 2; begin with Canvas do begin if oldIndex <> LB_Err then begin with PlayListBox do oldIndex := (oldIndex - TopIndex) * ItemHeight + Top - 5; Brush.Color := Self.Color; FillRect(Rect(Offset,oldIndex, Offset+15, oldIndex+15)); end; if newIndex <> LB_Err then begin with PlayListBox do newIndex := (newIndex - TopIndex) * ItemHeight + Top - 5; Draw(Offset, newIndex, aIcon); end; end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.ListDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; Var Accept: Boolean); Var curIndex: integer; begin if (Source is TCustomListBox) And (Sender is TCustomListBox) then begin Accept := True; { set the right drag cursors } if (State = dsDragEnter) then begin if Source = PlayListBox then begin if Sender = PlayListBox then Приложение А (продолжение) TListBox(Source).DragCursor := crTrackDrag else TFileListBox(Source).DragCursor := crTrackDelete; end else begin if Sender = FileListBox then TFileListBox(Source).DragCursor := crTrackDrag else TListBox(Source).DragCursor := crTrackAdd; end; aTimer.Enabled := False; DragTarget := TListBox(Sender); end else if (State = dsDragLeave) then aTimer.Enabled := True; { don't accept if on the scrollbars } with TCustomListBox(Sender) do begin CurIndex := ItemAtPos(Point(X,Y),False); if CurIndex = LB_Err then Accept := False; end; { now draw the index arrow } if (Sender = PlayListBox) then begin {special case for the last visible item } CurIndex := FindIndex(TListBox(Sender), Point(X, Y)); if (CurIndex <> oldIndex) Or (State = dsDragLeave) then begin if (State = dsDragEnter) then oldIndex := LB_Err; if (State = dsDragLeave) then curIndex := LB_Err; DrawIndexPtr(oldIndex, curIndex); oldIndex := curIndex; end; end; end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.ListDragDrop(Sender, Source: TObject; X, Y: Integer); Var aIndex: Integer; begin { make sure source and destination components are list boxes } if (Source is TCustomListBox) and (Sender is TCustomListBox) then begin if (Sender = FileListBox) then begin { delete selected items } if (Source = PlayListBox) then RemoveSelected; end else begin { copy from one list to another } if (Source = FileListBox) then begin Приложение А (продолжение) { find destination position in list box } aIndex := FindIndex(TListBox(Sender), Point(X, Y)); AddSelected(aIndex); end else { rearrange list } begin { find destination position in list box } aIndex := FindIndex(TListBox(Sender), Point(X, Y)); ResortSelected(aIndex); end; end; end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.ListEndDrag(Sender, Target: TObject; X, Y: Integer); begin aTimer.Enabled := False; DragTarget := Nil; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.Exit1Click(Sender: TObject); begin Close; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.NewPlaylist1Click(Sender: TObject); begin if SaveDialog.Execute then begin TempPlayList.Clear; PlayListBox.Clear; ListChanged := True; ListName := SaveDialog.FileName; end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.OpenPlaylist1Click(Sender: TObject); begin if OpenDialog.Execute then begin TempPlayList.Clear; PlayListBox.Clear; if LoadPlayList(OpenDialog.FileName,TempPlayList) then begin UpdatePlayListBox; ListChanged := False; ListName := OpenDialog.FileName; end else MessageDlg('Unable to load Playlist!',mtError, [mbOK],0); end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.SavePlaylist1Click(Sender: TObject); begin if SavePlayList(ListName,TempPlayList) then begin ListChanged := False; end else MessageDlg('Unable to save Playlist!',mtError, [mbOK],0); end; Приложение А (продолжение) {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.SavePlaylistAs1Click(Sender: TObject); begin SaveDialog.InitialDir := ExtractFilePath(ListName); SaveDialog.FileName := ExtractFileName(ListName); if SaveDialog.Execute then begin if SavePlayList(SaveDialog.FileName,TempPlayList) then begin ListChanged := False; ListName := SaveDialog.FileName; end else MessageDlg('Unable to save Playlist!',mtError, [mbOK],0); end; end; {-- TPlayListEditor -----------------------------------------------------} procedure TPlaylistEditor.AppendPlaylist1Click(Sender: TObject); begin if OpenDialog.Execute then begin if LoadPlayList(OpenDialog.FileName,TempPlayList) then begin UpdatePlayListBox; ListChanged := True; end else MessageDlg('Unable to append Playlist!',mtError, [mbOK],0); end; end; end. unit UPref; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, Tabnotbk, StdCtrls, ExtCtrls, MMObj, MMUtils, MMSlider, MMRegs, MMWaveIO, MMWavIn, MMWavOut, MMSpin; type TPreferencesForm = class(TForm) PageControl1: TPageControl; OptAudio: TTabSheet; btnOk: TButton; btnCancel: TButton; GroupBox1: TGroupBox; GroupBox2: TGroupBox; GroupBox3: TGroupBox; PlayCombo: TComboBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label6: TLabel; radioWindow: TRadioButton; radioThread: TRadioButton; radioInterrupt: TRadioButton; labelBufferSize: TLabel; sliderBufferSize: TMMSlider; spinBufferSize: TMMSpinButton; procedure FormShow(Sender: TObject); procedure BufferSizeChange(Sender: TObject); procedure btnOkClick(Sender: TObject); private BufferSize: integer; procedure UpdateBufferSize; end; var PreferencesForm: TPreferencesForm; implementation uses umain; {$R *.DFM} {========================================================================} { Initialization and Settings } {========================================================================} {-- TPreferencesForm ----------------------------------------------------} procedure TPreferencesForm.FormShow(Sender: TObject); var i: integer; begin with MainForm do begin {-- Audio Page --} sliderBufferSize.Position := WaveOut.NumBuffers; spinBufferSize.Value := sliderBufferSize.Position; BufferSize := sliderBufferSize.Position*WaveOut.BufferSize; UpdateBufferSize; if WaveOut.NumDevs > 0 then begin PlayCombo.Items.Add(WaveOutGetDeviceName(WAVE_MAPPER)); for i := 0 to WaveOut.NumDevs-1 do begin PlayCombo.Items.Add(WaveOutGetDeviceName(i)); end; PlayCombo.ItemIndex := WaveOut.DeviceId+1; end; if not _win95_ then radioInterrupt.Enabled := False;
Страницы: 1, 2, 3, 4, 5, 6, 7, 8
|