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

📄 adfax.pas

📁 测试用例
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  begin
    Result := PC12FaxData(Fax)^.fCData^.cSessionRes
  end;

  function TApdCustomAbstractFax.GetSessionWidth : Boolean;
    {-Return the session width}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cSessionWid
  end;

  function TApdCustomAbstractFax.GetSessionECM : Boolean;
    {-Return the session ECM}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cSessionECM
  end;

  function TApdCustomAbstractFax.GetHangupCode : Word;
    {-Return the last hangup code}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cHangupCode
  end;

  function TApdCustomAbstractFax.GetLastPageStatus : Boolean;
    {-Return the last page status}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cLastPageOK
  end;

  function TApdCustomAbstractFax.GetModemModel : TPassString;
    {-Return the modem model string}
  var
    HighClass : Char;
  begin
    if (FModemModel = '') and (not Fax^.aPData^.aInProgress) then begin
      {Make sure port is assigned}
      CheckPort;

      {Send the commands to get all info}
      fGetModemInfo(Fax, HighClass, FModemModel, FModemChip,
                    FModemRevision, False);
    end;
    Result := FModemModel;
  end;

  function TApdCustomAbstractFax.GetModemRevision : TPassString;
    {-Return the modem revision string}
  var
    HighClass : Char;
  begin
    if (FModemRevision = '') and (not Fax^.aPData^.aInProgress) then begin
      {Make sure port is assigned}
      CheckPort;

      {Send the commands to get all info}
      fGetModemInfo(Fax, HighClass, FModemModel, FModemChip,
                    FModemRevision, False);
    end;
    Result := FModemRevision;
  end;

  function TApdCustomAbstractFax.GetModemChip : TPassString;
    {-Return the modem chip string}
  var
    HighClass : Char;
  begin
    if (FModemChip = '') and (not Fax^.aPData^.aInProgress) then begin
      {Make sure port is assigned}
      CheckPort;

      {Send the commands to get all info}
      fGetModemInfo(Fax, HighClass, FModemModel, FModemChip,
                    FModemRevision, False);
    end;
    Result := FModemChip;
  end;

  function TApdCustomAbstractFax.GetModemBPS : LongInt;
    {-Return the highest BPS support by the modem}
  var
    C : Char;
  begin
    if not Fax^.aPData^.aInProgress then begin
      CheckPort;
      fGetModemFeatures(Fax, FModemBPS, C);
    end;
    Result := FModemBPS;
  end;

  function TApdCustomAbstractFax.GetModemECM : Boolean;
    {-Return True if the modem supports ECM}
  var
    C : Char;
  begin
    if not Fax^.aPData^.aInProgress then begin
      CheckPort;
      fGetModemFeatures(Fax, FModemBPS, C);
      FCorrection := C = '1';
    end;
    Result := FCorrection;
  end;

  function TApdCustomAbstractFax.GetTotalPages : Word;
    {-Return total pages to transmit, returns 0 when receiving}
  var
    Junk1 : Word;
    Junk2 : LongInt;
  begin
    fGetPageInfoC12(Fax, Result, Junk1, Junk2, Junk2)
  end;

  function TApdCustomAbstractFax.GetCurrentPage : Word;
    {-Return the current page, 0 for cover}
  var
    Junk1 : Word;
    Junk2 : LongInt;
  begin
    fGetPageInfoC12(Fax, Junk1, Result, Junk2, Junk2)
  end;

  function TApdCustomAbstractFax.GetBytesTransferred : LongInt;
    {-Return the bytes transferred for this page}
  var
    Junk1 : Word;
    Junk2 : LongInt;
  begin
    fGetPageInfoC12(Fax, Junk1, Junk1, Result, Junk2)
  end;

  function TApdCustomAbstractFax.GetPageLength : LongInt;
    {-Return the total bytes for this page, 0 when receiving}
  var
    Junk1 : Word;
    Junk2 : LongInt;
  begin
    fGetPageInfoC12(Fax, Junk1, Junk1, Junk2, Result)
  end;

  function TApdCustomAbstractFax.GetAbortNoConnect : Boolean;
    {-Return the AbortNoConnect setting}
  begin
    Result := Fax^.aPData^.afFlags and afAbortNoConnect <> 0
  end;

  procedure TApdCustomAbstractFax.SetAbortNoConnect(NewValue : Boolean);
    {-Enable/disable the AbortNoConnect option}
  begin
    with Fax^.aPData^ do
      if NewValue then
        afFlags := afFlags or afAbortNoConnect
      else
        afFlags := afFlags and not afAbortNoConnect;
  end;

  function TApdCustomAbstractFax.GetExitOnError : Boolean;
    {-Return the ExitOnError setting}
  begin
    Result := Fax^.aPData^.afFlags and afExitOnError <> 0
  end;

  procedure TApdCustomAbstractFax.SetExitOnError(NewValue : Boolean);
    {-Set the ExitOnError option}
  begin
    with Fax^.aPData^ do
      if NewValue then
        afFlags := afFlags or afExitOnError
      else
        afFlags := afFlags and not afExitOnError;
  end;

  function TApdCustomAbstractFax.GetSoftwareFlow : Boolean;
    {-Return the NoSoftwareFlow option}
  begin
    Result := Fax^.aPData^.afFlags and afSoftwareFlow <> 0
  end;

  procedure TApdCustomAbstractFax.SetSoftwareFlow(NewValue : Boolean);
    {-Set the NoSoftwareFlow option}
  begin
    with Fax^.aPData^ do
      if NewValue then
        afFlags := afFlags or afSoftwareFlow
      else
        afFlags := afFlags and not afSoftwareFlow;
  end;

  function TApdCustomAbstractFax.GetStatusInterval : Word;
    {-Return the status interval}
  begin
    Result := Fax^.aPData^.aStatusInterval;                         
  end;

  procedure TApdCustomAbstractFax.SetStatusInterval(NewValue : Word);
    {-Set a new status interval}
  begin
    Fax^.aPdata^.aStatusInterval := NewValue;                       
  end;

  function TApdCustomAbstractFax.GetDesiredBPS : Word;
    {-Return the desired BPS rate}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cMaxFaxBPS
  end;

  procedure TApdCustomAbstractFax.SetDesiredBPS(NewBPS : Word);
    {-Set the desired BPS}
  begin
    PC12FaxData(Fax)^.fCData^.cMaxFaxBPS := NewBPS;
  end;

  function TApdCustomAbstractFax.GetDesiredECM : Boolean;
    {-Return the desired ECM state}
  begin
    if PC12FaxData(Fax)^.fCData^.cCheckChar = '0' then
      Result := False
    else
      Result := True
  end;

  procedure TApdCustomAbstractFax.SetDesiredECM(NewECM : Boolean);
    {-Set a new desired ECM}
  const
    CharValue : array[Boolean] of Char = ('0', '1');
  begin
    PC12FaxData(Fax)^.fCData^.cCheckChar := CharValue[NewECM];
  end;

  function TApdCustomAbstractFax.GetFaxFileExt : TPassString;
    {-Return the fax file extension}
  begin
    Result := Fax^.aPData^.aFaxFileExt
  end;

  procedure TApdCustomAbstractFax.SetFaxFileExt(const NewExt : TPassString);
    {-Set a new fax file extension}
  begin
    Fax^.aPData^.aFaxFileExt := NewExt;
  end;

  procedure TApdCustomAbstractFax.apwFaxStatus(CP : TObject; First, Last : Boolean);
    {-Process the fax status message}
  begin
    if First then                                                        {!!.02}
      FStartTime := 0;                                                   {!!.02}
    if (FaxProgress = fpGotRemoteID) and (FStartTime = 0) then
      FStartTime := AdTimeGetTime;
    {Automatically hand off to status display, if one is attached}
    if Assigned(FStatusDisplay) then
      StatusDisplay.UpdateDisplay(First, Last);

    {Call the users status handler}
    if Assigned(FOnFaxStatus) then
      FOnFaxStatus(CP, First, Last);
  end;

  procedure TApdCustomAbstractFax.apwFaxLog(CP : TObject; LogCode : TFaxLogCode);
    {-Process the fax log message}
  begin
    {Automatically hand off to fax log, if one is attached}
    if Assigned(FFaxLog) then
      FaxLog.UpdateLog(LogCode);

    {Call the user log event}
    if Assigned(FOnFaxLog) then
      FOnFaxLog(CP, LogCode);

    {If receive is ending, clear the faxname field}
    {case LogCode of}                                                    {!!.04}
      {lfaxReceiveOK,}                                                   {!!.04}
      {lfaxReceiveFail,}                                                 {!!.04}
      {lfaxReceiveSkip :}                                                {!!.04}
        {FaxFile := '';}                                                 {!!.04}
    {end;}                                                               {!!.04}
  end;

  procedure TApdCustomAbstractFax.apwFaxError(CP : TObject;
                                              ErrorCode : Integer);
    {-Process the fax error message}
  begin
    if Assigned(FOnFaxError) then
      FOnFaxError(CP, ErrorCode);
  end;

  procedure TApdCustomAbstractFax.apwFaxFinish(CP : TObject;
                                               ErrorCode : Integer);
    {-Process the fax finish message}
  begin
    if Fax^.aPData^.aConcatFax then
      DeleteFile(FTempFile);
    if Assigned(FOnFaxFinish) then
      FOnFaxFinish(CP, ErrorCode);
    Fax^.aPData^.aFaxFileName := '';                                     {!!.04}
    if Assigned(FTapiDevice) then begin                                  {!!.04}
      CloseTapiPort;                                                     {!!.04}
      if (FaxMode = fmReceive) and (not TApdCustomReceiveFax(CP).OneFax) then{!!.04}
        TApdCustomReceiveFax(CP).TapiPassiveAnswer                       {!!.04}
      else                                                               {!!.04}
        UnprepareTapi;                                                   {!!.04}
    end;                                                                 {!!.04}
  end;

  procedure TApdCustomAbstractFax.CancelFax;
    {-Cancel the fax session}
  begin
    if (@FaxFunc <> nil) and (Fax^.aPData^.aInProgress) then
      FaxFunc(APW_FAXCANCEL, 0, LongInt(ComPort.Dispatcher.Handle) shl 16);
  end;

  function TApdCustomAbstractFax.StatusMsg(const Status : Word) : TPassString;
    {-Return a status message for Status}
  var
    P : array[0..MaxMessageLen] of Char;
  begin
    afStatusMsg(P, Status);
    Result := StrPas(P);
  end;

  function TApdCustomAbstractFax.LogMsg(const LogCode: TFaxLogCode): string;
    {-Return a string describing the log code }
  begin
    { strings defined in AdExcept.inc }
    case LogCode of
      lfaxNone          : Result := slfaxNone;
      lfaxTransmitStart : Result := slfaxTransmitStart;
      lfaxTransmitOk    : Result := slfaxTransmitOk;
      lfaxTransmitFail  : Result := slfaxTransmitFail;
      lfaxReceiveStart  : Result := slfaxReceiveStart;
      lfaxReceiveOk     : Result := slfaxReceiveOk;
      lfaxReceiveSkip   : Result := slfaxReceiveSkip;
      lfaxReceiveFail   : Result := slfaxReceiveFail;
    end;
  end;

  procedure TApdCustomAbstractFax.CheckPort;
    {-Set port's Dispatcher or raise exception}
  begin
    {Make sure comport is open, pass handle to fax}
    if Assigned(FComPort) then begin
      if (FComPort.DeviceLayer = dlWinSock) then
        raise ECannotUseWithWinSock.Create(ecCannotUseWithWinSock, False);

      { let the dispatcher handle the TAPI integration }
      {if (FComPort.TapiMode = tmOn) and (not FComPort.Open) then}       {!!.04}
        {raise ENotOpenedByTapi.Create(ecNotOpenedByTapi, False);}       {!!.04}
      {if Assigned(FTapiDevice) then}                                    {!!.04}
        {FComPort.TapiMode := tmOn;}                                     {!!.04}

      { if this returns nil, the port isn't open, raise the exception here }
      if ComPort.Dispatcher = nil then                                   {!!.04}
        raise ECommNotOpen.Create(ecCommNotOpen, False);                 {!!.04}

      fSetFaxPort(Fax, ComPort.Dispatcher);

      {Make sure output buffer is big enough}
      if ComPort.OutSize < 8192 then
        raise EOutputBufferTooSmall.Create(ecOutputBufferTooSmall, False);
    end else
      raise EPortNotAssigned.Create(ecPortNotAssigned, False);
  end;

  procedure TApdCustomAbstractFax.CreateFaxMessageHandler;
    {-Create message handler window}
  var
    Node : PFaxWindowNode;
    {$IFDEF VERSION3}
    Instance : Integer;
    {$ENDIF}
  begin
    {$IFDEF VERSION3}
    if ModuleIsLib and not ModuleIsPackage then
      Instance   := SysInit.hInstance
    else
      Instance   := System.MainInstance;
    {$ENDIF}
    MsgHandler :=
      CreateWindow(FaxHandlerClassName,        {window class name}
                   '',                         {caption}
                   0,                          {window style}
                   0,                          {X}
                   0,                          {Y}
                   0,                          {width}
                   0,                          {height}
                   0,                          {parent}
                   0,                          {menu}
                   {$IFDEF VERSION3}
                   Instance,
                   {$ELSE}
                   System.hInstance,

⌨️ 快捷键说明

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