Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > Oracle Database, SQL, Application, Programming


Printers


Reply
Views: 994  
Thread Tools Rate Thread
  #1  
Old 08-11-2010, 02:15 PM
bholas bholas is offline
Award Winner
 
Join Date: Apr 2010
Posts: 4,977
Default Printers

Printers" unit contains all most all the methods and properties you'd need to control Windows' printer interface. For example, you can easily retrieve the name of the default printer by using the "Printer" (ready to use instance of the "TPrinter" class) object of the "Printers" unit as follows:

uses Printers;

function GetDefaultPrinterName : string;
begin
if(Printer.PrinterIndex > 0)then
begin
GetDefaultPrinterName :=
Printer.Printers[
Printer.PrinterIndex ];
end else
begin
GetDefaultPrinterName := '';
end;
end;
If you want to display a list of available printers (using a "TComboBox" named "ComboBox1" for example):


ComboBox1.Items := Printer.Printers;
Changing the currently selected printer on the other hand is as easy as setting the "PrinterIndex" property. To use the first printer listed in the "Printers" property, set "PrinterIndex" to "0" (1st printer = 0, 2nd printer = 1, etc.).
You can also retrieve the status of a print job by using "Printing" and "Aborted" boolean properties.

Reply With Quote
Reply

Tags
programming tips

New topics in Oracle Database, SQL, Application, Programming





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)