Index
listscript.cgi id=20
rok 2027 20 23 (2)
rozdzial 02 (20)
rozdzial 06 (20)
rozdzial 20 (51)
20 (315)
20 (414)
PLIKI (20)
20 (123)
07 (60)
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • listy-do-eda.opx.pl

  • [ Pobierz całość w formacie PDF ]
    .VCL takes care of obtaining the DC, selectingthe appropriate objects into the DC, and releasing the DC when it is no longer needed.All you have to do is draw on the canvas and let VCL worry about the rest.So what does this have to do with printing? (Inquiring minds want to know.) Well,it's like this: Windows enables you to obtain a printer device context onwhich you can draw text, graphics, lines, and so on.In other words, you draw ona printer canvas just as you draw on a screen canvas.This concept represents quitea switch from the way printing was approached back in the good old days of DOS.Inthis case, it is Windows that comes to your rescue by enabling the use of a printerDC.VCL further aids you by encapsulating device contexts in the Canvas property.The bottom line is that printing is easier than it's ever been.The TPrinter Class and the Printer FunctionVCL aids in printing operations by providing the TPrinter class.This class encapsulatesthe whole of printing in Windows.TPrinter has a Canvas property that you can useto output lines, text, graphics, and other drawing objects to the printer.I don'twant to make it sound too easy, but all you have to do to print in your Delphi programsis add Printers to your uses list and then do something like the following:Printer.BeginDoc;Printer.Canvas.TextOut(20, 20, `Hello There!');Printer.EndDoc;In this code, Printer is a VCL function.This function enables you access to aTPrinter object that is set up and ready to go.All you have to do is put it to work.Now let's take a quick look at TPrinter's properties and methods.Table 13.5 liststhe primary TPrinter properties, and Table 13.6 shows the primary TPrinter methods.TABLE 13.5.TPrinter PROPERTIES.PropertyDescriptionAbortedThis property is True if printing was started and then aborted before it was finished.CanvasThe mechanism through which you can draw on the printer (the printer device context).CapabilitiesThe current settings of a printer device driver.CopiesThe number of copies printed.FontsA list of fonts supported by the current printer.HandleThe handle to the printer device context (HDC).Use this property when you have tocall a Windows API function that requires a handle to a device context.OrientationThe printer orientation (poPortrait or poLandsacpe).This is automatically set whenthe user chooses a printer or modifies the printer setup, but you can also set itmanually.PageHeightThe height of the current printer page in pixels.This value varies from printerto printer.In addition, this property can contain a different value based on theorientation of the printer.Some printers can use more than one resolution, whichalso causes this value to vary.PageNumberThe page number of the page currently printing.This property is incremented eachtime you call NewPage to begin printing a new page.PageWidthThe width of the page in pixels.As with the PageHeight property, this value variesdepending on the printer resolution, paper orientation, and paper size.PrinterIndexThe index value of the currently selected printer in the list of available printers.Specify -1 to select the default printer.PrintersA list of available printers on the system.PrintingThis property is True if the printer is currently printing.TitleThe text that identifies this printing job in the print manager window.TABLE 13.6.TPrinter METHODS.MethodDescriptionAbortUsed to abort the printing before normal completion.BeginDocBegins the printing process.Sets up the printer with Windows in preparation forprinting.EndDocEnds the printing process.Forces the current page to be printed and performs printingcleanup with Windows.GetPrinterRetrieves the current printer.Use the Printers property instead of this method.(The Printers property is the preferred method for accessing printers because youcan use it for both retrieving and setting the current printer.)NewPageUsed to force printing of the current page and start a new page.Increments the PageNumberproperty.SetPrinterSets the current printer.Use the Printers property instead of this method.The TPrinter class has no design-time interface.Everything is accomplished atruntime.Putting It to WorkIt's time to put your newly acquired knowledge to work.Once again it's time todust off the ScratchPad program and spruce it up a bit.After all, what good is atext editor that doesn't print?First, you need to modify the main form slightly.You already have menu itemsset up for the Print and Print Setup menu items, but you need to enable them andadd the Print and Printer Setup dialog boxes to the form.Here goes:1.Double-click the MainMenu component to bring up the Menu Designer.2.Choose File|Print from the ScratchPad menu in the Menu Designer.Changethe Enabled property to True.3.Do the same for the File|Print Setup menu item.Close the Menu Designer.4.Place a PrintDialog component on the form and change its Name propertyto PrintDialog.5.Place a PrinterSetupDialog on the form and change its Name propertyto PrinterSetupDialog.Okay, now that you've completed the form, it's time to go to work modifying thecode.To start, you have to add a couple items to the main form's declaration.Performthe following steps:1 [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • aceton.keep.pl
  • 
    Wszelkie Prawa Zastrzeżone! Kawa była słaba i bez smaku. Nie miała treści, a jedynie formę. Design by SZABLONY.maniak.pl.