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

📄 adfax.pas

📁 测试用例
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    ErrorCode : Integer;
    Temp      : SmallInt;
  begin
    Temp := word(wParam);
    ErrorCode := Temp;

    P := FindFax(hWindow);
    if Assigned(P) then begin
      Result := 0;
      case Msg of
        {General events}
        APW_FAXSTATUS :
          with P do
            apwFaxStatus(P, wParam = 1, wParam = 2);
        APW_FAXLOG :
          with P do
            apwFaxLog(P, TFaxLogCode(wParam));
        APW_FAXERROR :
          with P do
            apwFaxError(P, ErrorCode);
        APW_FAXFINISH :
          with P do
            apwFaxFinish(P, ErrorCode);

        {Receive events}
        APW_FAXNAME :
          with TApdReceiveFax(P) do begin
            apwFaxName(P, FFaxFile);
            afSetFaxName(Fax, FFaxFile);
          end;

        APW_FAXACCEPT :
          with TApdReceiveFax(P) do begin
            Accept := True;
            apwFaxAccept(P, Accept);
            Result := BoolRes[Accept];
          end;

        {Send events}
        APW_FAXNEXTFILE :
          with TApdSendFax(P) do begin
            apwFaxNext(P, Number, FName, CoverName);
            if Number <> '' then begin
              afSetNextFax(Fax, Number, FName, CoverName);
              Result := 1;
            end else
              Result := 0;
          end;
        else
          Result := DefWindowProc(hWindow, Msg, wParam, lParam);
      end;
    end else
      Result :=  DefWindowProc(hWindow, Msg, wParam, lParam);
  end;

  procedure RegisterFaxMessageHandlerClass;
  const
    Registered : Boolean = False;
  var
    XClass: TWndClass;
  begin
    if Registered then
      Exit;
    Registered := True;

    with XClass do begin
      Style         := 0;
      lpfnWndProc   := @FaxMessageHandler;
      cbClsExtra    := 0;
      cbWndExtra    := 0;
      {$IFDEF VERSION3}
      if ModuleIsLib and not ModuleIsPackage then
        hInstance   := SysInit.hInstance
      else
        hInstance   := System.MainInstance;
      {$ELSE}
      hInstance := System.hInstance;
      {$ENDIF}                                                       
      hIcon         := 0;
      hCursor       := 0;
      hbrBackground := 0;
      lpszMenuName  := nil;
      lpszClassName := FaxHandlerClassName;
    end;
    WinProcs.RegisterClass(XClass);
  end;

{TApdAbstractFax}

  function SearchStatusDisplay(const C : TComponent) : TApdAbstractFaxStatus;
    {-Search for a status display in the same form as TComponent}

    function FindStatusDisplay(const C : TComponent) : TApdAbstractFaxStatus;
    var
      I  : Integer;
    begin
      Result := nil;
      if not Assigned(C) then
        Exit;

      {Look through all of the owned components}
      for I := 0 to C.ComponentCount-1 do begin
        if C.Components[I] is TApdAbstractFaxStatus then begin
          {...and it's not assigned}
          if not Assigned(TApdAbstractFaxStatus(C.Components[I]).FFax) then begin
            Result := TApdAbstractFaxStatus(C.Components[I]);
            Exit;
          end;
        end;

        {If this isn't one, see if it owns other components}
        Result := FindStatusDisplay(C.Components[I]);
      end;
    end;

  begin
    {Search the entire form}
    Result := FindStatusDisplay(C);
  end;

  function SearchFaxLog(const C : TComponent) : TApdFaxLog;
    {-Search for a fax log in the same form as TComponent}

    function FindFaxLog(const C : TComponent) : TApdFaxLog;
    var
      I  : Integer;
    begin
      Result := nil;
      if not Assigned(C) then
        Exit;

      {Look through all of the owned components}
      for I := 0 to C.ComponentCount-1 do begin
        if C.Components[I] is TApdFaxLog then begin
          {...and it's not assigned}
          if not Assigned(TApdFaxLog(C.Components[I]).FFax) then begin
            Result := TApdFaxLog(C.Components[I]);
            Exit;
          end;
        end;

        {If this isn't one, see if it owns other components}
        Result := FindFaxLog(C.Components[I]);
      end;
    end;

  begin
    {Search the entire form}
    Result := FindFaxLog(C);
  end;

  constructor TApdCustomAbstractFax.Create(AOwner : TComponent);
    {-Create a TApdAbstractFax component}
  begin
    Fax := nil;
    inherited Create(AOwner);

    {Inits}
    FaxMode := fmNone;
    FModemModel := '';
    FModemChip := '';
    FModemRevision := '';
    FModemBPS := 0;
    FFaxFile := '';
    FSupportedFaxClasses := [];

    {Search for comport}
    FComPort := SearchComPort(Owner);

    {Force port values}
    if Assigned(FComPort) then with FComPort do begin
      Databits := 8;
      Stopbits := 1;
      Parity := pNone;
      Baud := 19200;
      InSize := 8192;
      OutSize := 8192;
      HWFlowOptions := [hwfUseRTS, hwfRequireCTS];
    end;

    {Search for fax status display}
    StatusDisplay := SearchStatusDisplay(Owner);

    {Search for fax log display}
    FaxLog := SearchFaxLog(Owner);

    {Initialize versioning info}
    FVersion := 0;

    FUserOnTapiPortOpen := nil;                                          {!!.04}
    FUserOnTapiPortClose := nil;                                         {!!.04}
    FUserOnTapiStatus := nil;                                            {!!.04}
  end;

  destructor TApdCustomAbstractFax.Destroy;
    {-Destroy a tApdAbstractFax component}
  var
    I : Integer;
    P : PFaxWindowNode;
  begin
    {Get rid of msg handler window and node}
    if not (csDesigning in ComponentState) then
      with FaxList do
        if Count > 0 then
          for I := 0 to Count-1 do begin
            P := PFaxWindowNode(Items[I]);
            if P^.fwFax = Self then begin
              DestroyWindow(P^.fwWindow);
              Remove(Items[I]);
              Dispose(P);
              break;
            end;
          end;

    inherited Destroy;
  end;

  function TApdCustomAbstractFax.GetFaxFile : TPassString;
    {-Return the fax file name}
  begin
    Result := FFaxFile;
  end;

  procedure TApdCustomAbstractFax.SetFaxFile(const NewFile : TPassString);
    {-Set the fax file name}
  begin
    FFaxFile := NewFile;
  end;

  function TApdCustomAbstractFax.GetInitBaud : Integer;
    {-Return the init baud rate}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cInitBaud
  end;

  procedure TApdCustomAbstractFax.SetInitBaud(const NewBaud : Integer);
    {-Set a new init baud rate}
  begin
    fSetInitBaudRate(Fax, NewBaud, NormalBaud,
                     not (csDesigning in ComponentState));
  end;

  function TApdCustomAbstractFax.GetNormalBaud : Integer;
    {-Return the normal baud rate}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cNormalBaud
  end;

  procedure TApdCustomAbstractFax.SetNormalBaud(const NewBaud : Integer);
    {-Set the normal baud rate}
  begin
    PC12FaxData(Fax)^.fCData^.cNormalBaud := NewBaud;
  end;

  function TApdCustomAbstractFax.GetFaxClass : TFaxClass;
    {-Return the fax class}
  begin
    Result := TFaxClass(Fax^.aPData^.aClassInUse)
  end;

  procedure TApdCustomAbstractFax.SetFaxClass(const NewClass : TFaxClass);
    {-Set the desired fax class}
  begin
    Fax^.aPData^.aClassInUse := OoMisc.ClassType(NewClass);
  end;

  function TApdCustomAbstractFax.GetModemInit : TModemString;
    {-Return the modem init string}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cModemInit
  end;

  procedure TApdCustomAbstractFax.SetModemInit(const NewInit : TModemString);
    {-Set the modem init string}
  begin
    fSetModemInit(Fax,NewInit);
  end;

  function TApdCustomAbstractFax.GetStationID : TStationID;
    {-Return the station ID}
  begin
    Result := Fax^.aPData^.aStationID
  end;

  procedure TApdCustomAbstractFax.SetStationID(const NewID : TStationID);
    {-Set a new station ID}
  begin
    Fax^.aPData^.aStationID := NewID;
  end;

  procedure TApdCustomAbstractFax.SetComPort(const NewPort : TApdCustomComPort);
    {-Set a new comport}
  begin
    if NewPort <> FComPort then begin
      FComPort := NewPort;
      if Assigned(FComPort) then with FComPort do begin
        {Force the critical comport properties}
        if not (csLoading in ComponentState) then begin
          OverrideLine := True;
          Databits := 8;
          Stopbits := 1;
          Parity := pNone;
          Baud := 19200;
          InSize := 8192;
          OutSize := 8192;
          HWFlowOptions := [hwfUseRTS, hwfRequireCTS];
        end;
      end;

      {If we switched comports we probably need new info}
      FModemModel := '';
      FModemChip := '';
      FModemRevision := '';
      FModemBPS := 0;
    end;
  end;

  procedure TApdCustomAbstractFax.SetStatusDisplay(
                                  const NewDisplay : TApdAbstractFaxStatus);
    {-Set the status display component}
  begin
    if NewDisplay <> FStatusDisplay then begin
      FStatusDisplay := NewDisplay;
      if Assigned(FStatusDisplay) then
        FStatusDisplay.FFax := Self;
    end;
  end;

  procedure TApdCustomAbstractFax.SetFaxLog(const NewLog : TApdFaxLog);
    {-Set the fax loggign component}
  begin
    if NewLog <> FFaxLog then begin
      FFaxLog := NewLog;
      if Assigned(FFaxLog) then
        FFaxLog.FFax := Self;
    end;
  end;

  function TApdCustomAbstractFax.GetRemoteID : TStationID;
    {-Return the remote's ID}
  begin
    Result := fGetRemoteID(Fax)
  end;

  function TApdCustomAbstractFax.GetSupportedFaxClasses : TFaxClassSet;
    {-Return the supported classes}
  var
    Class1, Class2, Class2_0 : Boolean;
  begin
    if not Fax^.aPData^.aInProgress then begin
      CheckPort;
      fGetModemClassSupport(Fax, Class1, Class2, Class2_0, False);
      Result := [];
      if Class1 then
        Include(Result, fcClass1);
      if Class2 then
        Include(Result, fcClass2);
      if Class2_0 then
        Include(Result, fcClass2_0);

      {Save it}
      FSupportedFaxClasses := Result;
    end else
      {Can't physically check because we're in progress, return last known}
      Result := FSupportedFaxClasses;
  end;

  function TApdCustomAbstractFax.GetFaxProgress : Word;
    {-Return the current fax progress code}
  begin
    Result := Fax^.aPData^.aFaxProgress
  end;

  function TApdCustomAbstractFax.GetFaxError : Integer;
    {-Return the current fax error code}
  begin
    Result := Fax^.aPData^.aFaxError
  end;

  function TApdCustomAbstractFax.GetSessionBPS : Word;
    {-Return the negotiated BPS}
  begin
    Result := PC12FaxData(Fax)^.fCData^.cSessionBPS
  end;

  function TApdCustomAbstractFax.GetSessionResolution : Boolean;
    {-Return the negotiated resolution (true for high, false for standard)}

⌨️ 快捷键说明

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