Autor Beitrag
Logiqu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP
Delphi 2006 Pro
BeitragVerfasst: Mo 21.11.05 12:55 
Hallo!

Wie kann ich aus meiner Anwendung heraus auf einen Drucker drucken, der nicht als Standard eingetragen ist? Der Druckername ist mir dabei bekannt. Muss ich dazu den Standard-Drucker kurzzeitig ändern oder gibt es noch andere Möglichkeiten.
Dabei soll nicht der PrintDialog verwendet werden müssen. Ich will also, dass der Drucker für die Anwendung beim Start gesetzt wird.

Vielen Dank im Voraus!

_________________
Logiqu. Just feel it...
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mo 21.11.05 14:15 
Schau mal in die DOH zum Thema TPrinter, das müsste dir weiterhelfen.

_________________
Bravery calls my name in the sound of the wind in the night...
Logiqu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP
Delphi 2006 Pro
BeitragVerfasst: Mo 21.11.05 14:39 
Ich nehme an, dass die Funktion SetPrinter am ehesten in Frage kommt. In der Hilfe steht aber nichts weiter als folgendes (Delphi 5):

"Die Methode SetPrinter legt einen Drucker als aktuellen Drucker fest.

procedure SetPrinter(ADevice, ADriver, APort: PChar; ADeviceMode: THandle);

Beschreibung

GetPrinter braucht nicht direkt aufgerufen zu werden. Verwenden Sie für den Zugriff auf einen Drucker das Array der Eigenschaft Printers. Weitere Informationen finden Sie in der Beschreibung der API-Funktion CreateDC."

Die Beschreibung scheint sich außerdem auf GetPrinter, statt SetPrinter zu beziehen. Also nicht wurklich eine Hilfe. Die Änderung des PrinterIndex ist leider auch wirkungslos.

_________________
Logiqu. Just feel it...
Logiqu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP
Delphi 2006 Pro
BeitragVerfasst: Mo 21.11.05 14:53 
Problem gelöst:

Ich hatte eine neue Instanz von TPrinter angelegt. TForm liefert aber selbst eine mit. Jetzt greife ich auf diese zu, setze den PrinterIndex und siehe da, es läuft!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
i := Printer.Printers.IndexOf(PrinterName);
if i >= 0 then
begin
  Printer.PrinterIndex := i;
end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.

_________________
Logiqu. Just feel it...