///////////////////////////////////////////////////////////////////////////////
// Introduction - DELPHI 2 ONLY
///////////////////////////////////////////////////////////////////////////////
Print preview module for TxyGraph, but may be used for any component
after copying component visual display into a metafile. I have used the
following components and code to create it...

I have used the very nice ryPrev32 code to create an alternative print preview
module - ryPrev by
rpetersn@usit.netunit
(loads of modifications by me - but thanks for the start)

I have used the fantastic Internet Explorer buttons provided by
Fabrice Deville - fdev@tornado.be
(no modifications by me)

And the most nifty PageSetupDlg component (the one that Borland forgot)
provided by Brad Stowers - bstowers@pobox.com or 72733,3374 on CompuServe.
(no modifications by me)

I have used the extremely excellent TStrechHandle component by
Anthony Scott - CIS: 75567,3547
(one modification by me)

and not used in the preview module, but recommended to all - TxyGraph by
Grahame Grieve, Kim Kirkpatrick
grahameg@kestral.com.au , kirkpatrick@nmhu.campus.mci.net
(no modifications by me)
A wonderful graph component - thanks very much.

All of the above are Freeware or Postcardware, and I have tried to contact the 
authors to ensure that they agree to this code being distributed as freeware
as well. Please acknowledge the authors of these components if you find this
Print preview module useful.

The original source code for the used components has been included for
the sake of completeness.
I have not enclosed the original code for TxyGraph because it is large, and
the print preview module does not need it, but the demo does. for this reason
I have included a compiled executable demo as well.
The xyGraph component can be found on the Delphi Super page, or
http://www.medstv.unimelb.edu.au/aas/xygraph.htm  --- I think.
///////////////////////////////////////////////////////////////////////////////
// Thanks to all of the above for their components and hard work
// I can't stress how grateful I am to all of you for the components
// you have created, and I hope you can find a use for this.
///////////////////////////////////////////////////////////////////////////////

Demo program, print preview module  by
John Biddiscombe - J.Biddiscombe@rl.ac.uk Jan 97

///////////////////////////////////////////////////////////////////////////////
// Instructions and information
///////////////////////////////////////////////////////////////////////////////
The program is a fairly complete Print Preview system.
To use it, you need to install
TExplBtn         

and the following components are used but created at
run time so no install needed.
TStretchHandle   
Tpgsetup         
TPanelWithCanvas 

Since I wrote it for use with TxyGraph, and the demo uses it, you should install
TxyGraph         

The main module is Print_Preview.pas heavily modified from ryPrev32, but not a
component simply include it in your uses clause.

How does it work.

Create a TPrintOut object like
My_print_preview := TPrintOut.Create;

create a metafile by whatever means you normally use.
then
My_print_preview.add_metafile( page_number_you_want_metafile_to_appear_on,
                               metafile,
                               xoffset,yoffset (inches) );
the metafile will be scaled to be about the same size in inches as it was on
the screen. Apologies if your metafile is not a screen pixel sized metafile.

Then do
My_print_preview.Preview;
and you'll see the page, you can move objects around, resize them etc etc and
you can add as many metafiles as you like.

several self explanatory buttons appear, the next page ones etc will be
disabled when only one page is used.

I wanted to be able to select a graph (or several) for printing, and then
position them by hand on the page, Of course I could paste them into Microsoft
Word and do it from there, but it's nice to have a built in feature for this.

Thanks to R.Peterson for the origianl ryPrev code, it got me wondering just
how fancy I could make it.

Enjoy

John B.

///////////////////////////////////////////////////////////////////////////////
// Bugs
///////////////////////////////////////////////////////////////////////////////
When you change printer orientation, the image in the box is not necessarily
correct, and the objects will remain in their prior positions, even though
the paper has changed (especially if you select envelope size) - they may be
off the paper. There's no real way of me knowing quite how to rescale everything
but that's why I wanted the resize handles etc etc.

The original ryPrev code had page numbers and support for text, but I stripped
the code down to the bare essentials and rebuilt it with the new capabilities,
I have not replaced the text features, so that may be worth someone doing.

The cursor control in TStretchhandles is a bit flaky, but I'm very impressed
with the control so I'm not going to complain - or did I just do so ?

I've not implemented Move_to_front Send_to_back, it'd be quite easy to do
but I want to keep this as a weekend project.
Also worth adding, would be align tops, lefts etc of boxes.

I couldn't think of an easy way of making metafiles span pages, so all objects
must be on one page. If you wanted to dump tons of text from a memo or similar
you'd have to break it into one-page-chunks.
The 2up and 4up page styles are not supported in this preview.
Envelopes look a bit funny too, should be easily fixed.

Not 100% tested yet, so let me know if you find anything dodgy.
I've only tried it on my printer at work. 

