OnClick Event

BJLBJL Brussels, Belgium
edited 7:11PM in FastReport 3.0
FR304 and BCB6

In some reports, I use the OnClick event to close the Preview, change the dataset and re-prepare the report, all under a single click.
In Fr 254, to close the preview, I have used successfully the following code, looping through the components to find the address of the PreviewForm.

<span style='font-family:Courier'> for (int i = frReport1->ComponentCount - 1; i >=0; i--)
{
if (dynamic_cast<TfrPreviewForm*>(frReport1->Components))
{
dynamic_cast<TForm*>(frReport1->Components)->Hide();
dynamic_cast<TForm*>(frReport1->Components)->Close();
}
}</span>

In FR 3, however, the compiler stops on the line

<span style='font-family:Courier'> if (dynamic_cast<TfrxPreviewForm*>(frxReport1->Components))</span>

with a message requesting a type name, as if TfrxPreviewForm was not defined.

Is there a different way to handle the code in FR3? Is there a better way to close the Preview from within the OnClick event?

Thank you for helping.

BJL

Comments

  • edited 7:11PM
    In the FR3.06 you can do the following:

    TForm(Report.Preview.Parent).Close;
  • BJLBJL Brussels, Belgium
    edited 7:11PM
    Thank you! I am now with FR3.06

    The BCB equivalent code

    <span style='font-family:Courier'> dynamic_cast<TForm*>(frxReport1->Preview->Parent)->Close();</span>

    works, but after that the newly prepared report does not stay on screen. It closes without stopping at the ShowPreparedReport.

    Is it a flag to restore?

    BJL
  • edited 7:11PM
    Could you send me a simple demo? Mine works well.
    tz@fast-report.com

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.