Ir para conteúdo
Fórum Script Brasil
  • 0

Problema com a configuração da bandeja (Delphi + QuickReport)


Eric Alves da Rochs

Pergunta

Boa tarde,

Estou com o seguinte problema:

o cliente utiliza a impressora Argox rabbit > driver label dr 200 - 4 inch model, a impressora está configurada (Configurações avançadas) para sair na bandeja "Tear off Enabled, porém quando abre o Preview, está selecionada outra bandeja ("w/o Cutter Peeler").

Estou procurando uma solução, pode ser para que o quickreport não altere essa bandeja de saída ou que eu possa alterar manualmente pelo delphi.

Fico no aguardo. Vou colocar a imagem das configurações avançadas sendo aberto pelo quickreport.

Untitled-1.jpg

desde já agradeço pela ajuda.

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 0

exemplo:

Uses Printers,WinSpool;

procedure GetPaperBins(sl: TStrings);
type
  TBinName      = array [0..23] of Char;
  TBinNameArray = array [1..High(Integer) div SizeOf(TBinName)] of TBinName;
  PBinnameArray = ^TBinNameArray;
  TBinArray     = array [1..High(Integer) div SizeOf(Word)] of Word;
  PBinArray     = ^TBinArray;
var
  Device, Driver, Port: array [0..255] of Char;
  hDevMode: THandle;
  i, numBinNames, numBins, temp: Integer;
  pBinNames: PBinnameArray;
  pBins: PBinArray;
begin
  //Printer.PrinterIndex := -1;
  Printer.GetPrinter(Device, Driver, Port, hDevmode);
  numBinNames := WinSpool.DeviceCapabilities(Device, Port, DC_BINNAMES, nil, nil);
  numBins     := WinSpool.DeviceCapabilities(Device, Port, DC_BINS, nil, nil);
  if numBins <> numBinNames then
  begin
    raise Exception.Create('DeviceCapabilities reports different number of bins and bin names!');
  end;
  if numBinNames > 0 then
  begin
    pBins := nil;
    GetMem(pBinNames, numBinNames * SizeOf(TBinname));
    GetMem(pBins, numBins * SizeOf(Word));
    try
      WinSpool.DeviceCapabilities(Device, Port, DC_BINNAMES, PChar(pBinNames), nil);
      WinSpool.DeviceCapabilities(Device, Port, DC_BINS, PChar(pBins), nil);
      sl.Clear;
      for i := 1 to numBinNames do
      begin
        temp := pBins^[i];
        sl.addObject(pBinNames^[i], TObject(temp));
      end;
    finally
      FreeMem(pBinNames);
      if pBins <> nil then
        FreeMem(pBins);
    end;
  end;
end;

procedure ChangePrinterBin(ToBin: Integer);
var
  ADevice, ADriver, APort: array [0..255] of Char;
  DeviceHandle: THandle;
  DevMode: PDeviceMode; // A Pointer to a TDeviceMode structure
begin
  { First obtain a handle to the TPrinter's DeviceMode structure }
  Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
  { If DeviceHandle is still 0, then the driver was not loaded. Set
    the printer index to force the printer driver to load making the
    handle available }
  if DeviceHandle = 0 then
  begin
    Printer.PrinterIndex := Printer.PrinterIndex;
    Printer.GetPrinter(ADevice, ADriver, APort, DeviceHandle);
  end;
  { If DeviceHandle is still 0, then an error has occurred. Otherwise,
    use GlobalLock() to get a pointer to the TDeviceMode structure }
  if DeviceHandle = 0 then
    Raise Exception.Create('Could Not Initialize TDeviceMode structure');

  DevMode := GlobalLock(DeviceHandle);

  DevMode^.dmFields := DevMode^.dmFields or DM_DEFAULTSOURCE;
  DevMode^.dmDefaultSource := ToBin;

  Printer.SetPrinter(ADevice, ADriver, APort, DeviceHandle);

  GlobalUnlock(DeviceHandle);
end;

procedure SetPrinterBin( Printername : pchar; BinCode : integer );
var
SpaceNeeded : word;
pDBuff : _devicemodeA;
Driver_info_2 : pDriverinfo2;
DevModeSize : integer;
dPtr : Pointer;
begin
OpenPrinter(Printername, hPrinter, nil);
// find out how much space we need for the info stuct
GetPrinter( hPrinter, 2, 0, 0, @SpaceNeeded);
// allocate the necessary
GetMem( Driver_info_2, SpaceNeeded);
// The second GetPrinter fills in all the current settings
GetPrinter( hPrinter, 2, Driver_info_2, SpaceNeeded, @SpaceNeeded);
// If GetPrinter didn't fill in the DEVMODE, try to get it by calling
// Documentproperties() - this is always true in Delphi, so ...
DevModeSize := DocumentProperties(0, hPrinter, Printername,
pDBuff, pDBuff, 0); // Zero returns buffer size. */
// get space
dPtr := allocmem( DevModeSize );
devmode := pDevmode( dPtr );
// this call fills our struct
DocumentProperties(0, hPrinter, Printername,
_devicemodeA( dPtr^), pDBuff, DM_OUT_BUFFER );
// make changes to devmode
devmode^.dmFields := DM_DEFAULTSOURCE;
devmode^.dmDefaultSource := BinCode;
// implement the change ...
try
//SetPrinter( hPrinter, 2, devmode, 0);
except
end;
// make sure all of devmode is copied back
DocumentProperties(0, hPrinter, Printername,
_devicemodeA( dPtr^), _devicemodeA(
dPtr^), DM_IN_BUFFER+DM_OUT_BUFFER );
FreeMem( Driver_info_2, SpaceNeeded);
freemem( dPtr, DevmodeSize);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
   GetPaperBins(list.Items);
   SetPrinterBin(word(List.Objects[0]));
end;

ou pode ver esses links

http://www.swissdelphicenter.com/en/showcode.php?id=796

http://coding.derkeiler.com/Archive/Delphi...4/msg00071.html

abraço

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...