trichview.support
Re: Choose pre-define custom paper size |
Author |
Message |
Yernar |
Posted: 02/01/2003 17:37:26 This example shows how to change papersize without user: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Printers, RVStyle, ExtCtrls, RVScroll, RichView, PtblRV, StdCtrls; type TPaperForm = class(TForm) PaperRichView: TRichView; PaperPanel: TPanel; ExtraRVStyle: TRVStyle; PrintButton: TButton; RVPrint1: TRVPrint; psd: TPrinterSetupDialog; procedure FormCreate(Sender: TObject); procedure PrintButtonClick(Sender: TObject); private public end; var PaperForm: TPaperForm; implementation {$R *.DFM} procedure PreparePrinter(); var Device, Driver, Port: array[0..80] of Char; DevMode: THandle; pDevmode: PDeviceMode; begin {Get printer device name etc.} Printer.GetPrinter(Device, Driver, Port, DevMode); {force reload of DEVMODE} Printer.SetPrinter(Device, Driver, Port, 0); {get DEVMODE handle} Printer.GetPrinter(Device, Driver, Port, DevMode); if Devmode <> 0 then begin {lock it to get pointer to DEVMODE record} pDevMode := GlobalLock(Devmode); if pDevmode <> nil then try with pDevmode^ do begin {modify paper size} dmPapersize := DMPAPER_A3; {tell printer driver that dmPapersize field contains data it needs to inspect} dmFields := dmFields or DM_PAPERSIZE; end; finally {unlock DEVMODE handle} GlobalUnlock(Devmode); end; end; end; procedure TPaperForm.FormCreate(Sender: TObject); begin PreparePrinter; with PaperRichView do begin LoadRVF('history.rvf'); Format; end; end; procedure TPaperForm.PrintButtonClick(Sender: TObject); var PrintIt: Boolean; begin PrintIt := psd.Execute; if PrintIt then begin RVPrint1.AssignSource(PaperRichView); RVPrint1.FormatPages(rvdoALL); if RVPrint1.PagesCount > 0 then RVPrint1.Print('Paper Demo', 1, False); end; end; end. |
Powered by ABC Amber Outlook Express Converter