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

📄 mmwavprp.pas

📁 一套及时通讯的原码
💻 PAS
字号:
{========================================================================}
{=                (c) 1995-98 SwiftSoft Ronald Dittrich                 =}
{========================================================================}
{=                          All Rights Reserved                         =}
{========================================================================}
{=  D 01099 Dresden             = Fax.: +49 (0)351-8037944              =}
{=  Loewenstr.7a                = info@swiftsoft.de                     =}
{========================================================================}
{=  Actual versions on http://www.swiftsoft.de/mmtools.html             =}
{========================================================================}
{=  This code is for reference purposes only and may not be copied or   =}
{=  distributed in any format electronic or otherwise except one copy   =}
{=  for backup purposes.                                                =}
{=                                                                      =}
{=  No Delphi Component Kit or Component individually or in a collection=}
{=  subclassed or otherwise from the code in this unit, or associated   =}
{=  .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed     =}
{=  without express permission from SwiftSoft.                          =}
{=                                                                      =}
{=  For more licence informations please refer to the associated        =}
{=  HelpFile.                                                           =}
{========================================================================}
{=  $Date: 04.08.98 - 01:07:24 $                                        =}
{========================================================================}
unit MMWavPrp;

{$I COMPILER.INC}

interface

uses
{$IFDEF WIN32}
    Windows,
{$ELSE}
    WinTypes,
    WinProcs,
{$ENDIF}
    SysUtils,
    Consts,
    Classes,

{$IFDEF DELPHI6}
    DesignIntf,
    DesignEditors,
{$ELSE}
    DsgnIntf,
{$ENDIF}

    MMObj,
    MMDSPObj,
    MMWave,
    MMCstDlg,
    MMWPlay,
    MMWRec,
    MMACMDlg;

type
  {-- TMMWaveFileProperty ------------------------------------------------}
  TMMWaveFileProperty = class(TStringProperty)
  public
    procedure Edit; override;
    function  GetAttributes: TPropertyAttributes; override;
    procedure SetValue(const aValue: string); override;
  end;

  {-- TMMWaveProperty ----------------------------------------------------}
  TMMWaveProperty = class(TClassProperty)
  public
    function  GetAttributes: TPropertyAttributes; override;
    function  GetValue: string; override;
    procedure SetValue(const aValue: string); override;
  end;

  {-- TMMWaveComponentEditor ---------------------------------------------}
  TMMWaveComponentEditor = class(TComponentEditor)
  public
    procedure ExecuteVerb(Index: Integer); override;
    function  GetVerb(Index: Integer): string; override;
    function  GetVerbCount: Integer; override;
  end;

  {-- TMMWaveFormatProperty ----------------------------------------------}
  TMMWaveFormatProperty = class(TStringProperty)
  public
    procedure Edit; override;
    function  GetAttributes: TPropertyAttributes; override;
  end;

  {-- TMMWaveFormatComponentEditor --------------------------------------}
  TMMWaveFormatComponentEditor = class(TComponentEditor)
  public
    procedure ExecuteVerb(Index: Integer); override;
    function  GetVerb(Index: Integer): string; override;
    function  GetVerbCount: Integer; override;
  end;

implementation

{== TMMWaveFileProperty ==================================================}
function TMMWaveFileProperty.GetAttributes: TPropertyAttributes;
begin
   Result := [paDialog];
end;

{-- TMMWaveFileProperty --------------------------------------------------}
procedure TMMWaveFileProperty.Edit;
var
   aFileName: TFileName;

begin
   with TMMWaveOpenDialog.Create(nil) do
   try
      aFileName := GetValue;
      if FileExists(aFileName) then
      begin
         InitialDir := ExtractFilePath(aFileName);
         FileName := ExtractFileName(aFileName);
      end;
      if Execute then SetValue(FileName);

   finally
      Free;
   end;
end;

{-- TMMWaveFileProperty --------------------------------------------------}
procedure TMMWaveFileProperty.SetValue(const aValue: string);
begin
   inherited SetValue(UpperCase(aValue));
end;

{== TMMWaveProperty ======================================================}
function TMMWaveProperty.GetAttributes: TPropertyAttributes;
begin
   Result := [paSubProperties];
end;

{-- TMMWaveProperty ------------------------------------------------------}
function TMMWaveProperty.GetValue: string;
Var
   aWave: TMMWave;

begin
   aWave := TMMWave(GetOrdValue);
   if aWave.Empty and ((aWave.FileName = '')or(not aWave.FileMustExist)) then
      Result := {$IFDEF DELPHI3}srNone{$ELSE}LoadStr(srNone){$ENDIF}
   else
      Result := '(TMMWave)';
end;

{-- TMMWaveProperty ------------------------------------------------------}
procedure TMMWaveProperty.SetValue(const aValue: string);
begin
   if aValue = '' then SetOrdValue(0);
end;

{== TMMWaveComponentEditor ===============================================}
procedure TMMWaveComponentEditor.ExecuteVerb(Index: Integer);
Var
   aFileName: TFileName;

begin
   aFileName := '';
   with TMMWaveOpenDialog.Create(nil) do
   try
      if (Component is TMMCustomWaveFile) then
         aFileName := (Component as TMMCustomWaveFile).Wave.FileName
      else if (Component is TMMCustomWaveEditor) then
         aFileName := (Component as TMMCustomWaveEditor).Wave.FileName
      else if (Component is TMMWavePlayer) then
         aFileName := (Component as TMMWavePlayer).Wave.FileName
      else if (Component is TMMWaveRecorder) then
         aFileName := (Component as TMMWaveRecorder).Wave.FileName;

      if (aFileName <> '') and FileExists(aFileName) then
      begin
         FileName := ExtractFileName(aFileName);
         InitialDir := ExtractFilePath(aFileName);
      end;

      if Execute then
      begin
         if (Component is TMMCustomWaveFile) then
            (Component as TMMCustomWaveFile).Wave.FileName := FileName
         else if (Component is TMMCustomWaveEditor) then
            (Component as TMMCustomWaveEditor).Wave.FileName := FileName
         else if (Component is TMMWavePlayer) then
            (Component as TMMWavePlayer).Wave.FileName := FileName
         else if (Component is TMMWaveRecorder) then
            (Component as TMMWaveRecorder).Wave.FileName := FileName;

         if (Designer <> nil) then Designer.Modified;
      end;

   finally
      Free;
   end;
end;

{-- TMMWaveComponentEditor -----------------------------------------------}
function TMMWaveComponentEditor.GetVerb(Index: Integer): string;
begin
   Result := LoadResStr(IDS_WAVESELECTFILE);
end;

{-- TMMWaveComponentEditor -----------------------------------------------}
function TMMWaveComponentEditor.GetVerbCount: Integer;
begin
   Result := 1;
end;

{== TMMWaveFormatProperty ================================================}
function TMMWaveFormatProperty.GetAttributes: TPropertyAttributes;
begin
   Result := [paDialog];
end;

{-- TMMWaveFormatProperty ------------------------------------------------}
procedure TMMWaveFormatProperty.Edit;
var
   ACM: TMMACM;
   Component: TComponent;

begin
   Component := TComponent(GetComponent(0));

   if (Component <> nil) and (Component is TMMDSPComponent) then
   with (Component as TMMDSPComponent) do
   begin
      ACM := TMMACM.Create(nil);
      try
         if (Component is TMMWaveRecorder) then
            ACM.EnumFormats := efInput
         else
            ACM.EnumFormats := efAll;

         if ACM.ChooseFormat(PWaveFormat,'Select Format') then
         begin
            PWaveFormat := ACM.PWaveFormat;
            if (Designer <> nil) then Designer.Modified;
         end;

      finally
         ACM.Free;
      end;
   end;
end;

{== TMMWaveFormatComponentEditor ==============================================}
procedure TMMWaveFormatComponentEditor.ExecuteVerb(Index: Integer);
var
   ACM: TMMACM;

begin
   if (Component <> nil) and (Component is TMMDSPComponent) then
   with (Component as TMMDSPComponent) do
   begin
      ACM := TMMACM.Create(nil);
      try
         if (Component is TMMWaveRecorder) then
            ACM.EnumFormats := efInput
         else
            ACM.EnumFormats := efAll;

         if ACM.ChooseFormat(PWaveFormat,'Select Format') then
         begin
            PWaveFormat := ACM.PWaveFormat;
            if (Designer <> nil) then Designer.Modified;
         end;
      finally
         ACM.Free;
      end;
   end;
end;

{-- TMMWaveFormatComponentEditor ----------------------------------------------}
function TMMWaveFormatComponentEditor.GetVerb(Index: Integer): string;
begin
   Result := 'Select WaveFormat...';
end;

{-- TMMWaveFormatComponentEditor ----------------------------------------------}
function TMMWaveFormatComponentEditor.GetVerbCount: Integer;
begin
   Result := 1;
end;

end.

⌨️ 快捷键说明

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