I have dropped a QRPreview component on a form.
Created an OnPreview event:-
which sets QRPreview->QRPrinter=QuickRep->QRPrinter;
which then calls the Preview form
However when the preview for displays it does not display the report.
Has anyone created a custom preview which works? if so help please.
On Sun, 19 Apr 1998 03:09:41 +1200, sli...@xtra.co.nz (Craig Hubbard)
wrote:
Ctor of the frmPrev preview form :
__fastcall TfrmPrev::TfrmPrev(TComponent* Owner, TQuickRep
*kQuickChutes)
: TForm(Owner)
{
QuickChutes = kQuickChutes;
}
I am using this like that
PrintDialog1->MinPage = 1;
PrintDialog1->MaxPage = QRPreview1->QRPrinter->PageCount;
PrintDialog1->FromPage = 1;
PrintDialog1->ToPage = QRPreview1->QRPrinter->PageCount;
if (PrintDialog1->Execute() == TRUE)
{
QuickChutes->PrinterSettings->FirstPage = PrintDialog1->FromPage;
QuickChutes->PrinterSettings->LastPage = PrintDialog1->ToPage;
QuickChutes->PrinterSettings->Copies = PrintDialog1->Copies;
QRPreview1->QRPrinter->Title = "Wait for end of print";
QuickChutes->ShowProgress = TRUE;
Screen->Cursor = crHourGlass;
QRPreview1->QRPrinter->Print();
Screen->Cursor = crDefault;
}
Hope this will do - I have not a lot of time now.
Gerard
On Mon, 20 Apr 1998 20:13:51 +1200, sli...@xtra.co.nz (Craig Hubbard)
wrote:
>Gerard,
Saw your message on the news group and wanted to give you a much cleaner
example
for corrected you problem. I had the exact same thing happen to me and after
much
work came up with the following solution.
In the OnPreview event for the TQuickRep you would create the Custom Preview
form and set the QPrinter for the preview object to the QPrinter of the
QuickRep
For Example:
void __fastcall QuickRep::OnPreview(void)
{
TCustomPreview* CustomPreview = new TCustomPreview(this);
CustomPreview->QRPreview->QRPrinter = dynamic_cast<TQRPrinter*>(Sender);
}
You might need to add CustomPreview->Show if you form is not preconfiged with
Visible = true;
Now when you call QuickRep->Preview, your custom preview window will show.
Because the Preview call is modeless, you do not want to delete this
CustomPreview
when you return from the function call. Instead you simply need to free to
form when it
closes. To do this on the Custom Preview form add an event for FormClose
like this:
void __fastcall TCustomPreview::OnClose(void)
{
QRPreview->QRPrinter = NULL;
Free();
}
I have used this with much success. The real trick was not to delete the
Preview window
explicitly. The reason is that since the Preview call is modeless the user
can go back to the
application without closing the window and therefore exit the program without
closign the
window. Since you don't call delete on the CustomPreview and let it free
itself, you don't
run into the situation where the CustomPreview is NULL.
One additional item. Since you are creating and new form for each preview
you should
not set the CustomPreview variable to the global CustomPreview variable that
is created,
nor should you autocreate the form on startup.
John McDermott
john_mc...@hp.com