- Delphiartiklar, tips, forum, länksamling - 

      

START | DELPHI | LÄNKARGÄSTBOK 




 Forum

Grundkurs
  »Introduktion
  »Snabbguide
  »Komponenter
  »Händelser
  »Strängar
  »Räkna med Delphi   »Egna typer
  »Selektion
  »Iteration
  »Menyer
  »Funktioner
  »Arraystrukturer

Tips & Tricks
  »Nya tips
  »Blandat
  »Databaser
  »Filer
  »Forms
  »Grafik
  »Internet
  »Komponenter
  »Matematik
  »Multimedia
  »Objekt/ActiveX
  »Skrivare
  »Strängar
  »System
  »Mest lästa tips

Artiklar
  »Delphi och ADO
  »Bygga en DLL
  »Skapa en enkel rapport
  »Hantera registret
  »Enheter, units
  »Klassen TCanvas
  »Använd LookUp Controls

 Nya tips
 Lägg till tips
 Delphilänkar
 Gästbok

 

Visa dialogrutan för skrivaregenskaper Kategori: Skrivare
Inlagt: 2003-02-15
Läst: 1297
Inlagt av: Staffan Berg
Beskrivning
Detta exempel visar upp rutan där du kan se egenskaper för angiven skrivare. 
Kod
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;


 
 
© Copyright 2005 - Staffan Berg
- Alla rättigheter förbehålles -