Question
“How can display the Preview as part of a form?”
Solution
This example shows how to create an instance of the Preview plug-in and display it on a panel. The Preview is a non-visual class that managers the viewer, toolbar, outline and other UI controls. It requires a parent, which can be a form or a panel.
Download: PreviewInPanel.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
uses ppPreview; procedure TForm1.FormCreate(Sender: TObject); begin FPreview := TppPreviewPlugIn.CreatePreviewPlugin(Panel1); FPreview.Viewer.Report := ppReport1; FPreview.OnClose := ehPreview_CloseEvent; end; procedure TForm1.FormDestroy(Sender: TObject); begin FPreview.Free; FPreview := nil; end; procedure TForm1.Button1Click(Sender: TObject); begin if FPreview.Viewer.Busy then Exit; FPreview.BeforePreview; if ppReport1.InitializeParameters then // optionally display the autosearch dialog if ppReport1.DisplayAutoSearchDialog then begin FPreview.Viewer.Reset; ppReport1.PrintToDevices; end; end; procedure TForm1.ehPreview_CloseEvent(Sender: TObject); begin Close; end; |