was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

47 Visitors Online


 
...den Eigenschaften Dialog eines Druckers anzeigen?
Autor: Thomas Stutz
[ Tip ausdrucken ]  

Tip Bewertung (8):  
     


{
  If you need to create your own printer dialog, you can use the PrinterProperties
  API function to bring up a printer's properties dialog.
}

uses
  
WinSpool, Printers;

procedure TForm1.Button1Click(Sender: TObject);
const
  
{
   The TPrinterDefaults structure specifies the default data type,
   environment, initialization data, and access rights for a printer.
  }
  
Defaults: TPrinterDefaults = (pDatatype: nil;
    pDevMode: nil;
    DesiredAccess: STANDARD_RIGHTS_REQUIRED or PRINTER_ACCESS_USE);
var
  
hPrinter: THandle;
  Device: array[0..255] of char;
  Driver: array[0..255] of char;
  Port: array[0..255] of char;
  hDeviceMode: THandle;
  RetVal: Boolean;
begin
  
Printer.PrinterIndex := Combobox1.ItemIndex;
  { Retrieve information about the specified printer }
  
Printer.GetPrinter(Device,
    Driver,
    Port,
    hDeviceMode);
  { Retrieve a handle identifying the specified printer or print }
  
if not OpenPrinter(@Device, hPrinter, @Defaults) then
    
RaiseLastWin32Error;
  try
    
{ Display a printer-properties property sheet for the specified printer }
    
PrinterProperties(Handle, hPrinter);
  finally
    
{ Close the specified printer object }
    
ClosePrinter(hPrinter);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  
{ Show available printers in a Combobox }
  
Combobox1.Items := Printer.Printers;
  Combobox1.ItemIndex := 0;
end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners