Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QuickReport v2.0i &BCB 3 Custom Preview

61 views
Skip to first unread message

Craig Hubbard

unread,
Apr 19, 1998, 3:00:00 AM4/19/98
to

Having problems creating a custom preview form for QuickReport version 2.

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.

gerard patel

unread,
Apr 19, 1998, 3:00:00 AM4/19/98
to

Hello Craig
Yes I have done this - It is rather messy. I had one report
with QR 1 and Bcb 1 and nothing worked anymore with
Bcb 3 - and no docs on the upgrade, no howto convert
your old reports, nothing.
I had to patch things hastily and this how I have done it.
There has to be easier ways, of course.
- 1 form with the QReport component. This is the form I am
loading from my app. In the Form Create event, I call the
constructor of my preview form, with a pointer to the QuickReport
component.
I enable then a timer component on the QReport form, the timer event
hides the QReport form and calls the preview method of the
QuickReport component. This form is closed in the
QuickReport afterPreview event.
- 1 preview form with the QRPreview component.
This form gets a pointer to the QuickReport component from
the QuickReport form. This pointer is used because you need
it in the QReport 1.0 methods that used the QRPrinter object.
It seems that this object don't exist anymore whatever the so-called
'documentation' says .
Very important : in the Form Close event, set Action to caFree.
This works, but if you manage to make this a little clearert, I would
be thankful.
HTH
Gerard


On Sun, 19 Apr 1998 03:09:41 +1200, sli...@xtra.co.nz (Craig Hubbard)
wrote:

Craig Hubbard

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

Gerard,
Could you show me the syntax you use to assign a pointer to the QRPreview
or email me some sample units that you have used, just to show me the
syntax.
Craig Hubbard

gerard patel

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to

Craig
To call the preview form :
frmPrev = new TfrmPrev(this, QuickChutes);

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,

John G McDermott

unread,
Apr 20, 1998, 3:00:00 AM4/20/98
to Craig Hubbard

Craig,

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

Craig Hubbard

unread,
Apr 21, 1998, 3:00:00 AM4/21/98
to

Thanx John.
This has solved my problem.
Simple once you know how, I wish the author or Borland could have
answered this.
I had contacted the quSoft but rather than answer the problem, all they
could do is agree that it was frustrating.
Thanx for you solution it really did waste a lot of our time.
Craig

0 new messages