tags:

views:

46

answers:

1

Friends

I use RR to produce print previews, based on a single TRVSystem (setting Modal to false, and redirecting the onPrint function to produce each preview, picking up and using the TBasereport.

It works well, but I need to ensure that all modeless report windows are shut on program close in order to avoid exceptions.

Do I need to locate/enumerate the report windows in order to close them?

A: 

You can enumerate all open forms using the Screen singleton object and check if they are of a given TForm devivative type. If so, close down those forms:

var
  F: TCustomForm;
  i: Integer;
begin
  for i := Screen.FormCount - 1 downto 0 do begin
    F := Screen.Forms[ i ];
    if F is TMySpecialFormType then F.Free();
  end;
end;
Ritsaert Hornstra
The F variable is not needed.
jachguate
@jachguate: O yes that can be, and sometimes accessing properties ahve side effects, and cost extra CPU cycles. Code also needs error handling, but I thought that this is an example to explain and I thought this way it is the most clear example code.
Ritsaert Hornstra
It all worked nicely when I discovered that the open forms were named 'Rave....'.All I had then to do was to close those ones.
Paul Laughlin