Can the preview window's size be controlled?
If I set frxReport.PreviewOptions.Maximized := true, I get a full screen preview. If I set it false, then I get a very small window. Is there any way to programmatically control the size of the window that opens when it's not maximized?
If not, could FastReport be enhanced to remember the size of the last preview window when it was closed? I.e., once the user manually adjusts the size of the preview window, it would be nice if that would be come the default size for a non-maximized window (for that user only).
Comments
G'day Alan,
I don't know about "controlled", but you might be able to use a trick we have applied in another area.
Assuming your Report Component is called "AReport" you should be able to do something like:
[code]
with TfrxPreviewForm (AReport.PreviewForm) do begin
Height := 800;
Width := 1400;
end;
[/code]
in your code before you invoke the Preview.
I haven't tried it, but in our test-bed just now I did check the values of these Properties on a Report Preview that was maximised on a Laptop with a small screen. The Debug Trace Log showed:
"Forums#17567-GLOWreportCommons.PreviewShow: Height 784 x Width 1382"
You'll need to work out your own method for making the settings variable (by User or Admin) if hard-coding them isn't enough...
Cheers, Paul
Thanks Paul!
I did some hunting through the documentation looking for “PreviewForm”, but the only thing I can find is a very brief section in the programmers’ manual. It mentions that “TfrxPreview should be on the component pallet, but my FR installation doesn’t include it (I have the professional edition, just downloaded from the site 2 weeks ago).
Nevertheless, I was successful creating a TForm as the parent of a dynamically created TPreview -- sure enough the preview comes up in my own window. But none of the settings I have in place for the PreviewOptions are respected – how can you link the TfrxReport.PreviewOptions to a custom preview window?
G'day Alan,
OK I did a bit more digging.
I don't know if the Edition is significant in this case (we have "Enterprise" but I don't think it is that different from "Professional").
Bit of background first...
Our major App has 30-40 reports each declared in its own Unit / Form and descended from a common "Template". This is declared the usual way:
The descendants are declared as you would expect:
We have a single Unit that handles Common Functions for FastReports, and that declares:
which sets our standard PreviewOptions (as overriden by User Preferences set in Registry / IniFile.
The Report Template Unit calls PreviewSetup from within the code that it executes to create and preview the report.
It might seem elaborate and overly complex, but it does give us a common "look and feel", facilitates user-managed options, and allows new reports to be created really fast!
In passing we did originally "hard-wire" the PreviewOptions on the TfrxReport Component in the Template Unit and the settings flowed on to the descendant reports, but the code was enhanced a while back in response to user requests to be "dynamic".
So I don't know why your PreviewOptions are being ignored, it sounds like you have a similar set-up.
Cheers, Paul
P.S. the same Common Functions code manages PrintOptions, ReportOptions and the settings for exporting reports to PDFs.
P.
I discovered that TfrxPreview is on my component pallet, but it's hidden when you're working with a DataModule -- which is where we've got our TfrxReport component . This makes some sense.
As for my original problem of not being able to control the preview window size, I have that working too.
What I still can't quite figure out is how to get the toolbar to appear on my custom preview window. I've looked at the EmbedDesigner demo project, which uses a TfrxPreview component, and it doesn't show the toolbar either. Is that a limitation of custom previews?
G'day Alan,
Good to hear progress is being made.
Dumb question, does the setting of the PreviewOptions.Buttons Property include pbTools?
Again our "Report Commons" code sets this in our PreviewSetupButtons Method.
For clarity:
[code]
PreviewOptions.Buttons := PreviewOptions.Buttons + [pbZoom];
[/code]
Cheers, Paul
Oh sorry, I copied the wrong line! 🤕 It should have been [pbTools].
The other "mea culpa" is that I have now played with this setting and it doesn't seem to affect anything. I don't seem to be able to hide the Preview Toolbar!
So back to square one.
Sorry, Paul
Thanks again for your help Paul. At this point I've got a working preview window with a home-grown tool bar that implements only those functions we would have enabled via the PreviewOptions.Buttons property. It really wasn't as much work as I expected it would be, the TfrxReport's methods do most of the heavy lifting, all you really need to do is to define a UI and hook the OnClick / OnChange handlers to the appropriate methods.