⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 realmng.pas

📁 关于DEPHI7.0的播放器管理系统源代码
💻 PAS
字号:
unit realmng;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ToolWin, ComCtrls, Inifiles;

type
  TFormRealMng = class(TForm)
    Label1: TLabel;
    Edit_site: TEdit;
    BTN_OK: TButton;
    ListBox1: TListBox;
    Panel1: TPanel;
    BTN_Cancel: TButton;
    GroupBox1: TGroupBox;
    ToolBar1: TToolBar;
    BTN_Del: TButton;
    BTN_Clear: TButton;
    BTN_About: TButton;
    BTN_Export: TButton;
    BTN_close: TButton;
    SaveDialog1: TSaveDialog;
    procedure FormCreate(Sender: TObject);
    procedure Edit_siteChange(Sender: TObject);
    procedure BTN_CancelClick(Sender: TObject);
    procedure BTN_OKClick(Sender: TObject);
    procedure BTN_ExportClick(Sender: TObject);
    procedure BTN_ClearClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BTN_AboutClick(Sender: TObject);
    procedure BTN_DelClick(Sender: TObject);
    procedure BTN_closeClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    RealFile : Tinifile;  //列表文件
    ListCount, ListIndex : Integer; //网址数、网址号
    procedure  ListBoxScrollar(Sender: TObject);
  end;

var
  FormRealMng: TFormRealMng;

implementation
uses about, RealPlayer;
{$R *.dfm}

procedure TFormRealMng.ListBoxScrollar(Sender: TObject);
var
i, MaxWidth: integer; 
begin 
  MaxWidth := 0;
  for i := 0 to ListBox1.Items.Count - 1 do
    if MaxWidth < ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i]) then
       MaxWidth := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i]);
  SendMessage(ListBox1.Handle, LB_SETHORIZONTALEXTENT, MaxWidth+20, 0);
end;

procedure TFormRealMng.FormCreate(Sender: TObject);
var i : Integer;
FileTemp : String;
begin
  RealFile := Tinifile.create(ExtractFilePath(paramstr(0))+'Media.Ini');
  ListCount := RealFile.ReadInteger('Real网址','网址数',0);
  for i:=0 to ListCount-1 do
     begin
       FileTemp := RealFile.ReadString('网址列表','No.['+inttostr(i)+']','');
       ListBox1.Items.Add(FileTemp);
     end;
  ListIndex := RealFile.ReadInteger('Real网址','网址号',-1);
  ListBox1.ItemIndex := ListIndex;
  ListBoxScrollar(Sender);
end;

procedure TFormRealMng.Edit_siteChange(Sender: TObject);
begin
 if Edit_site.Text <> '' then
    BTN_OK.Enabled := True;
end;

procedure TFormRealMng.BTN_CancelClick(Sender: TObject);
begin
  Edit_site.Text := '';
  BTN_OK.Enabled := False;
end;

procedure TFormRealMng.BTN_OKClick(Sender: TObject);
var Temp : String;
begin
  if Edit_site.Text ='' then exit;
  Temp := Edit_site.Text;
  ListBox1.Items.Add(Temp);
  ListBox1.ItemIndex := ListBox1.Count - 1;
  ListIndex := ListBox1.ItemIndex;
  ListCount := ListBox1.Count;
  RealFile.WriteString('网址列表','No.['+inttostr(ListCount-1)+']',Temp);
  RealFile.WriteInteger('Real网址','网址数',ListCount);
  RealFile.WriteInteger('Real网址','网址号',ListIndex);
  ListBoxScrollar(Sender);
  Edit_site.Clear;
  BTN_OK.Enabled := False;
end;

procedure TFormRealMng.BTN_ExportClick(Sender: TObject);
var i: Integer;
FileTemp : String;
JlrFile : TextFile;
begin
   if ListBox1.Items.Count <= 0 then exit;
   SaveDialog1.Title := '请输入要保存的文件名,以.jlr结束';
   if SaveDialog1.Execute then
   try
     begin
       assignFile(JlrFile, SaveDialog1.FileName);
       rewrite(JlrFile);
         try
           for i :=0 to ListBox1.Items.Count -1 do
              begin
                FileTemp := ListBox1.Items.Strings[i];
                writeln(JlrFile, FileTemp);
              end;
         finally
           CloseFile(JlrFile);
         end;
     end;
   except
     showmessage('无法保存此文件!');
   end;
end;

procedure TFormRealMng.BTN_ClearClick(Sender: TObject);
begin
  if ListCount <= 0 then exit; //如果列表中为空则退出
  ListCount := 0;
  ListIndex := -1;
  Realfile.WriteInteger('Real网址','网址数',ListCount);
  Realfile.WriteInteger('Real网址','网址号',ListIndex);
  Realfile.EraseSection('网址列表');
  ListBox1.Clear;
  ListBoxScrollar(Sender);
end;

procedure TFormRealMng.FormClose(Sender: TObject;
  var Action: TCloseAction);
var i : Integer;
FileTemp : String;
begin
  FormRealPlayer.Cmb2.Clear;
  ListCount := RealFile.ReadInteger('Real网址','网址数',0);
  for i:=0 to ListCount-1 do
     begin
       FileTemp := RealFile.ReadString('网址列表','No.['+inttostr(i)+']','');
       FormRealPlayer.Cmb2.Items.Add(FileTemp);
     end;
  ListIndex := RealFile.ReadInteger('Real网址','网址号',-1);
  FormRealPlayer.Cmb2.ItemIndex := ListIndex;
end;

procedure TFormRealMng.BTN_AboutClick(Sender: TObject);
begin
  FormAbout.Show;
end;

procedure TFormRealMng.BTN_DelClick(Sender: TObject);
var
  Index : Integer;
begin
        if ListCount <= 0 then exit;      //如果列表中为空则退出
        Index := ListBox1.ItemIndex;
        if Index < 0 then exit;           //如果没有选择则退出
         //如果被删除的是当前正在打开的网址,则关闭该连接
        if FormRealPlayer.RealAudio1.Source = ListBox1.Items.Strings[Index] then
        begin
          FormRealPlayer.RealAudio1.DoStop;
          ListIndex := -1;
          RealFile.WriteInteger('Real网址','网址号',ListIndex);
        end;
        //从列表中删除
        ListBox1.Items.Delete(Index);
        //列表文件总数减一
        ListCount := ListCount-1;
        if ListCount = 0 then
          begin
          ListIndex := -1;
          RealFile.WriteInteger('Real网址','网址号',ListIndex);
          end;
        if Index = ListCount then
          begin
          ListBox1.ItemIndex :=0;
          ListIndex :=  ListBox1.ItemIndex;
          RealFile.WriteInteger('Real网址','网址号',ListIndex);
          end
        else
          begin
          ListBox1.ItemIndex := index;
          ListIndex :=  ListBox1.ItemIndex;
          RealFile.WriteInteger('Real网址','网址号',ListIndex);
          end;
        RealFile.WriteInteger('Real网址','网址数',ListCount);
        for Index := Index to ListCount-1 do
        begin
          RealFile.WriteString ('网址列表','No.['+inttostr(Index)+']',
                         ListBox1.Items.Strings[Index]);
        end;
        ListBoxScrollar(Sender);
        RealFile.DeleteKey('网址列表','No.['+inttostr(ListCount)+']');
end;

{
var i: Integer;
FileTemp : String;
JlrFile : TextFile;
begin
   if ListBox1.Items.Count <= 0 then exit;
   SaveDialog1.Title := '请输入要保存的文件名,以.jlr结束';
   if SaveDialog1.Execute then
   try
     begin
       assignFile(JlrFile, SaveDialog1.FileName);
       rewrite(JlrFile);
         try
           for i :=0 to ListBox1.Items.Count -1 do
              begin
                FileTemp := ListBox1.Items.Strings[i];
                writeln(JlrFile, FileTemp);
              end;
         finally
           CloseFile(JlrFile);
         end;
     end;
   except
     showmessage('无法保存此文件!');
   end;
}

procedure TFormRealMng.BTN_closeClick(Sender: TObject);
begin
 Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -