Using Delphi 3.0 Pro and Quick Reports 2.0k (the QR supplied with D3,
updated with patch from web - problem also existed with QR 2.0c). I've
searched the net and can't find a solution, hopefully someone here can
tell me what I'm doing wrong.
stripped down .pas files demonstrating this problem are at the end of
this post...
My app's main form (named FM_Main for purposes of this message) has a
button that pops up a dialog (FM_Dialog) that lists the available
reports. FM_Dialog in turn has a button that displays a custom preview
form (FM_Preview).
The problem occurs if FM_Main calls FM_Dialog.ShowModal; After
pressing the preview button on FM_Dialog you cannot close FM_Dialog.
If FM_Main calls FM_Dialog.Show, however, you can close FM_Dialog
after previewing the report, with no problem.
I can't make sense of why this would even be occurring - it seems to
me that you should be able to close the FM_Dialog form after it calls
the FM_Preview form, regardless of how FM_Dialog was called from
FM_Main.
Any help greatly appreciated!
Project forms listed here:
MAIN - The applications main form. Has a button to display FM_Dialog.
DIALOG - Called by FM_Main, this form has the "Preview" button.
PREVIEW - Included for reference, in case my screw-up is here.
REPORT - Included for reference, in case my screw-up is here.
************ BEGIN MAIN FORM ************
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Grids, DBGrids, Db, DBTables;
type
TFM_Main = class(TForm)
BT_Close: TButton;
BT_Dialog: TButton;
DBG_Main: TDBGrid;
DS_Main: TDataSource;
TL_Main: TTable;
TL_MainPROJECT: TStringField;
procedure BT_DialogClick(Sender: TObject);
procedure BT_CloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FM_Main: TFM_Main;
implementation
uses Rept, Preview, Dialog;
{$R *.DFM}
procedure TFM_Main.BT_DialogClick(Sender: TObject);
{This is the problem point - if ShowModal below is replaced with Show}
{then FM_Dialog can be closed with no problem after it's BT_Preview}
{button has been clicked}
begin
FM_Dialog.ShowModal;
end;
procedure TFM_Main.BT_CloseClick(Sender: TObject);
begin
Close;
end;
end.
************ END MAIN FORM ************
************ BEGIN DIALOG FORM ************
unit Dialog;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls;
type
TFM_Dialog = class(TForm)
BT_Close: TButton;
BT_Preview: TButton;
procedure BT_CloseClick(Sender: TObject);
procedure BT_PreviewClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FM_Dialog: TFM_Dialog;
implementation
uses Preview, Rept;
{$R *.DFM}
procedure TFM_Dialog.BT_CloseClick(Sender: TObject);
begin
FM_Dialog.Close;
end;
procedure TFM_Dialog.BT_PreviewClick(Sender: TObject);
begin
FM_Preview.Show;
FM_Report.QuickRep1.Preview;
end;
end.
************ END DIALOG FORM ************
************ BEGIN PREVIEW FORM ************
unit Preview;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, qrprntr, Buttons;
type
TFM_Preview = class(TForm)
BT_Close: TBitBtn;
PL_Speedbar: TPanel;
QR_Preview: TQRPreview;
procedure BT_CloseClick(Sender: TObject);
private
public
end;
var
FM_Preview: TFM_Preview;
implementation
uses Rept;
{$R *.DFM}
procedure TFM_Preview.BT_CloseClick(Sender: TObject);
begin
Close;
end;
end.
************ END PREVIEW FORM ************
************ BEGIN REPORT FORM ************
unit Rept;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls;
type
TFM_Report = class(TForm)
QuickRep1 : TQuickRep;
TitleBand1 : TQRBand;
QRLabel1 : TQRLabel;
DetailBand1 : TQRBand;
QRDBText1: TQRDBText;
procedure QuickRep1Preview(Sender: TObject);
private
public
end;
var
FM_Report: TFM_Report;
implementation
uses Main, QRPrntr, Preview;
{$R *.DFM}
procedure TFM_Report.QuickRep1Preview(Sender: TObject);
begin
FM_Preview.QR_Preview.QRPrinter := TQRPrinter(Sender);
end;
end.
************ END REPORT FORM ************
--
Kobayashi Software - Chicago, Illinois
www.kobayashi.com - e...@kobayashi.com
--
Kobayashi Software - Chicago, Illinois
www.kobayashi.com - e...@kobayashi.com