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

📄 sendfax0.pas

📁 delphi RS232 计算机串口通讯源程序
💻 PAS
📖 第 1 页 / 共 2 页
字号:
       (sfFaxList.PhoneNumber <> '') and
       (sfFaxList.FaxName <> '') then begin
      {add this fax entry to the list}
      S := sfFaxList.PhoneNumber + '^' + sfFaxList.FaxName;
      if sfFaxList.CoverName <> '' then
        S := S + '^' + sfFaxList.CoverName;
      FaxList.Add(S);

      {add this fax entry to the list box}
      S := Format('%-20S %-20S %-20S',
                  [LimitS(sfFaxList.PhoneNumber, 20),
                   LimitS(sfFaxList.FaxName, 20),
                   LimitS(sfFaxList.CoverName, 20)]);
      sfFaxListBox.Items.Add(S);
    end;
  end;

  AddsInProgress := False;
end;

procedure TsfMain.sfAddClick(Sender: TObject);
  {-Handle an Add request from the form button}
begin
  sfAppendAddList('', '', '');
  sfAddPrim;
end;

procedure TsfMain.sfAddFromPrinterDriver(var Message: TMessage);
  {-Handle an Add request message send by APFSENDF.DRV printer driver}
var
  JobID  : Word;
  KeyBuf : array[0..8] of Char;
  zFName : array[0..255] of Char;
begin
  {The message received from the printer driver has a job identifier
   in the wParam field.  This job identifier points to an entry in the
   SendFax.Ini file which the printer driver has added.  As SendFax
   handles each message, it should delete that job entry from the Ini
   file and queue the job for display in the Add dialog.}
  with Message do begin
    JobID := wParam;
    StrCopy(KeyBuf, 'Job');
    KeyBuf[3] := Chr(Lo(JobID));
    KeyBuf[4] := #0;
    GetPrivateProfileString('FaxJobs', KeyBuf, '', zFName, sizeof(zFName),
                            'SENDFAX.INI');
    {now delete the entry so the ID can be re-used by the printer driver}
    WritePrivateProfileString('FaxJobs', KeyBuf, nil, 'SENDFAX.INI');
  end;

  sfAppendAddList(StrPas(zFName), '', '');

  if not AddsInProgress then
    sfAddPrim;
end;

procedure TsfMain.sfAddFromCmdLine;
  {-Handle an Add request specified on the command line}
begin
  if ParamStr(1) = '/F' then begin
    sfAppendAddList(ParamStr(2), '', '');

    if not AddsInProgress then
      sfAddPrim;
  end;
end;

procedure TsfMain.ApdSendFax1FaxNext(CP: TObject;
                                     var ANumber, AFileName,
                                     ACoverName: TPassString);
  {-Return the next fax to send}
var
  S : String;
  CaretPos : Byte;
begin
  if FaxList.Count = 0 then Exit;
  try
    S := FaxList[FaxIndex];
    CaretPos := Pos('^', S);
    ANumber := Copy(S, 1, CaretPos-1);
    S := Copy(S, CaretPos+1, 255);
    CaretPos := Pos('^', S);
    if CaretPos = 0 then begin
      AFileName := S;
      ACoverName := '';
    end else begin
      AFileName := Copy(S, 1, CaretPos-1);
      ACoverName := Copy(S, CaretPos+1, 255);
    end;
    Inc(FaxIndex);
  except
    ANumber := '';
    AFileName := '';
    ACoverName := '';
  end;
end;

procedure TsfMain.ApdSendFax1FaxFinish(CP: TObject; ErrorCode: Integer);
  {-Display a finished message}
begin
  ShowMessage('Finished: ' + ErrorMsg(ErrorCode));
  if ApdComPort1.TapiMode = tmOn then
    if ApdTapiDevice1.CancelCall then
      {Call cancelled immediately, clear InProgress flag}
      InProgress := False
    else
      {CancelCall proceeding in background, waiting for OnTapiPortClose}
  else begin
    {Not using TAPI, just close the port and clear the InProgress flag}
    ApdComPort1.Open := False;
    InProgress := False;
  end;
end;

procedure TsfMain.sfExitClick(Sender: TObject);
  {-Exit the application}
var
  TempEntry : PAddEntry;
begin
  while AddList <> nil do begin
    TempEntry := AddList;
    AddList := AddList^.NextEntry;
    FreeMem(TempEntry, SizeOf(TAddEntry));
  end;
  Close;
end;

procedure TsfMain.sfModifyClick(Sender: TObject);
  {-Modify the selected fax entry}
var
  SaveIndex : Integer;
  CPos : Word;
  S : String;
begin
  if InProgress then begin
    MessageBeep(0);
    Exit;
  end;

  {Exit if nothing selected}
  if sfFaxListBox.ItemIndex = -1 then
    Exit;

  {Set the button text}
  sfFaxList.flAction.Caption := '&Modify';

  {Note the listbox index, use it get data from FileList}
  SaveIndex := sfFaxListBox.ItemIndex;
  S := FaxList[SaveIndex];
  CPos := Pos('^', S);
  sfFaxList.PhoneNumber := Copy(S, 1, CPos-1);
  S := Copy(S, CPos+1, 255);
  CPos := Pos('^', S);
  if CPos = 0 then
    sfFaxList.FaxName := S
  else begin
    sfFaxList.FaxName := Copy(S, 1, CPos-1);
    sfFaxList.CoverName := Copy(S, CPos+1, 255);
  end;

  {Show the dialog}
  if sfFaxList.ShowModal = mrOK then begin
    {Modify the FaxList entry}
    S := sfFaxList.PhoneNumber + '^' + sfFaxList.FaxName;
    if sfFaxList.CoverName <> '' then
      S := S + '^' + sfFaxList.CoverName;
    FaxList.Strings[SaveIndex] := S;

    {Add this fax entry to the list box}
    S := Format('%-20S %-20S %-20S',
                [LimitS(sfFaxList.PhoneNumber, 20),
                 LimitS(sfFaxList.FaxName, 20),
                 LimitS(sfFaxList.CoverName, 20)]);
    sfFaxListBox.Items[SaveIndex] := S;
  end;
end;

procedure TsfMain.sfDeleteClick(Sender: TObject);
  {-Delete the selected fax entry}
var
  Index : Word;
begin
  if InProgress then begin
    MessageBeep(0);
    Exit;
  end;

  if sfFaxListBox.ItemIndex <> -1 then begin
    Index := sfFaxListBox.ItemIndex;
    sfFaxListBox.Items.Delete(Index);
    FaxList.Delete(Index);
  end;
end;

procedure TsfMain.ApdSendFax1FaxLog(CP: TObject; LogCode: TFaxLogCode);
  {-Remote this fax entry from the lists, if finished okay}
begin
  if LogCode = lfaxTransmitOK then begin
    Dec(FaxIndex);
    sfFaxListBox.Items.Delete(FaxIndex);
    FaxList.Delete(FaxIndex);
  end;
end;

procedure TsfMain.sfFaxClassClick(Sender: TObject);
  {-Set the new desired fax class}
begin
  ApdSendFax1.FaxClass := TFaxClass(sfFaxClass.ItemIndex+1);
end;

procedure TsfMain.sfDialAttemptsChange(Sender: TObject);
  {-Set the new desired dial attempts}
begin
  try
    ApdSendFax1.DialAttempts := StrToInt(sfDialAttempts.Text);
  except
  end;
end;

procedure TsfMain.sfRetryWaitChange(Sender: TObject);
  {-Set the new desired retry wait}
begin
  try
    ApdSendFax1.DialRetryWait := StrToInt(sfRetryWait.Text);
  except
  end;
end;

procedure TsfMain.sfStationIDChange(Sender: TObject);
  {-Set the new station ID}
begin
  ApdSendFax1.StationID := sfStationID.Text;
end;

procedure TsfMain.sfDialPrefixChange(Sender: TObject);
  {-Set the new dial prefix}
begin
  ApdSendFax1.DialPrefix := sfDialPrefix.Text;
end;

procedure TsfMain.sfModemInitChange(Sender: TObject);
  {-Set the new modem init string}
begin
  ApdSendFax1.ModemInit := sfModemInit.Text;
end;

procedure TsfMain.sfHeaderChange(Sender: TObject);
  {-Set the new header line}
begin
  ApdSendFax1.HeaderLine := sfHeader.Text;
end;

procedure TsfMain.sfSelectComPortClick(Sender: TObject);
begin
  ApdTapiDevice1.SelectDevice;
end;

procedure TsfMain.ApdTapiDevice1TapiPortOpen(Sender: TObject);
begin
  {TAPI port is configured and open, star the fax session}
  ApdSendFax1.StartTransmit;
end;

procedure TsfMain.ApdTapiDevice1TapiPortClose(Sender: TObject);
begin
  InProgress := False;
end;

procedure TsfMain.HdrFontBtnClick(Sender: TObject);
begin
  FontDialog1.Font.Assign(ApdSendFax1.EnhHeaderFont);
  if FontDialog1.Execute then
    ApdSendFax1.EnhHeaderFont.Assign(FontDialog1.Font);
end;

procedure TsfMain.CvrFontBtnClick(Sender: TObject);
begin
  FontDialog1.Font.Assign(ApdSendFax1.EnhFont);
  if FontDialog1.Execute then
    ApdSendFax1.EnhFont.Assign(FontDialog1.Font);
end;

end.

⌨️ 快捷键说明

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