Autor Beitrag
Gambler
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mi 08.12.04 13:03 
Hi,

also Frage ergibt sich ja aus dem Topic. Ich habe einen Drucker mit unterschiedlichen Fächern
und möchte diese einzeln ansteuern können. Einer ne Idee wie das geht?

Gruß
Andre
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 08.12.04 13:09 
Hast du es schon mit dem TPrintDialog probiert?
Oder willst du den Drucker direkt ansteuern?
Mit QuickReport kann es problematisch werden.
Gambler Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mi 08.12.04 14:42 
Der Dialog liefert mir leider keine Informationen über Fächer. Dialoge kämen eh nicht in Frage da das Programm als Daemon im Hintergrund laufen soll.
Spatz
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

WIN 2k
D7E
BeitragVerfasst: Fr 10.12.04 09:09 
um die fächer auszulesen:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
type
  TBin  = record
    Id:   integer;
    Name: String;
  end;
  TBins = array of TBin;

[...]

function TDrucken.getPaperBins(printerId: integer): TBins;
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:      array [0..255] of Char;
  Driver:      array [0..255] of Char;
  Port:        array [0..255] of Char;
  hDevMode:    THandle;
  i:           integer; 
  numBinNames: integer; 
  numBins:     integer;
  pBinNames:   PBinnameArray;
  pBins:       PBinArray;
begin
  Printer.PrinterIndex := printerId;
  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
    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);
      SetLength(Result, numBinNames - 1);
      for i := 1 to numBinNames do
      begin
        Result[i - 1].Id   := pBins^[i];
        Result[i - 1].Name := pBinNames^[i];
      end;
    finally
      FreeMem(pBinNames);
      if pBins <> nil then
        FreeMem(pBins);
    end;
  end;
end;


und zum den Schacht zu wählen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TDrucken.setPaperBin(binNr: integer);
var
  aDevice: array[0..255] of char;
  aDriver: array[0..255] of char;
  aPort:   array[0..255] of char;
  hDMode:  THandle;
  PDMode:  PDEVMODE;
begin
  Printer.GetPrinter(aDevice, aDriver, aPort, hDMode);
  if hDMode <> 0 then begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin
      pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE;
      pDMode^.dmPaperSize := DMPAPER_A4;
      pDMode^.dmFields := pDMode^.dmFields or DM_DEFAULTSOURCE;
      pDMode^.dmDefaultSource := binNr;
      GlobalUnlock(hDMode);
    end;
  end;
end;