无对话框打印

时间:2021-04-22 09:02:49

标签: delphi winapi

有一个用于打印标签的程序cablabel s3 lite。在编辑中,输入条码,当您按 Enter 键时,将发送文件进行打印。有必要在发送打印时,不显示打印对话框并且我的程序表单保持活动状态。我正在尝试使用 ShellExecuteEx 函数执行此操作:

procedure TForm1.EditBarcodeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
const
  Dir = 'Labels\';
var
  SEInfo: TShellExecuteInfo;
  ExecuteFile: string;
begin
  if Key = 13 then
  begin
    ExecuteFile := Dir + EditBarcode.Text + '.stc';
    FillChar(SEInfo, SizeOf(SEInfo), 0);
    SEInfo.cbSize := SizeOf(TShellExecuteInfo);
    with SEInfo do
    begin
      fMask := SEE_MASK_NOCLOSEPROCESS;
      Wnd := Application.Handle;
      lpVerb := 'print';
      lpFile := PChar(ExecuteFile);
      nShow := SW_SHOWMINNOACTIVE;
    end;
    try
      Win32Check(ShellExecuteEx(@SEInfo));
    finally
      EditBarcode.SetFocus;
      EditBarcode.SelectAll;
    end;
  end;
end;

但无济于事。告诉我如何正确操作。

0 个答案:

没有答案
相关问题