How do I keep your Confirm dialog from showing when closing the designer
Greetings,
Delphi 5.1
RB Pro 7.03
I have this code in the designer onCloseQuery event:
procedure TdtmQueryExplorer.ppDesignerCloseQuery(Sender: TObject;
var CanClose: Boolean);
Var
Res:Byte;
begin
If ppReport1.Modified { Designer.Report.Modified }Then
Begin
Res := MsgDlg('Report is changed, Save now?', '', mtConfirmation,
[mbYes, mbNo, mbCancel], 0);
If Res = MrCancel Then
Begin
CanClose := False;
End
Else
Begin
If Res = mrYes Then
ppReport1.Template.SaveToFile;
End;
End;
end;
My problem is that your internal Confirm dialog will display asking to "Save
changes to the New Report". Then after I select no on your dialog, the
above code fires. I'm sure I have some setting wrong somewhere. Can you
tell me what I need to do to disable your dialog and allow me to use my own
for saving?
Thanks,
Michael Tuttle
Software Technologies, Inc.
Topeka, KS
Delphi 5.1
RB Pro 7.03
I have this code in the designer onCloseQuery event:
procedure TdtmQueryExplorer.ppDesignerCloseQuery(Sender: TObject;
var CanClose: Boolean);
Var
Res:Byte;
begin
If ppReport1.Modified { Designer.Report.Modified }Then
Begin
Res := MsgDlg('Report is changed, Save now?', '', mtConfirmation,
[mbYes, mbNo, mbCancel], 0);
If Res = MrCancel Then
Begin
CanClose := False;
End
Else
Begin
If Res = mrYes Then
ppReport1.Template.SaveToFile;
End;
End;
end;
My problem is that your internal Confirm dialog will display asking to "Save
changes to the New Report". Then after I select no on your dialog, the
above code fires. I'm sure I have some setting wrong somewhere. Can you
tell me what I need to do to disable your dialog and allow me to use my own
for saving?
Thanks,
Michael Tuttle
Software Technologies, Inc.
Topeka, KS
This discussion has been closed.
Comments
Turns out that at design time the ppReport component did have the the
SaveAsTemplate set to False, but at run time when the designer form was
closed, the following code fire and aReport.SaveAsTemplate was marked to
true.
function TppDesignerWindow.SaveQuery(aReport: TppCustomReport): Boolean;
begin
{default result is true}
Result := True;
if (aReport = nil) or not (aReport.SaveAsTemplate) or
not (aReport.Modified) then Exit;
...
end;
Not sure how aReport.SaveAsTemplate was set to True when I had it set to
false at design time, so I placed this code snipped and now it works as
expected.
procedure TdtmQueryExplorer.ppDesignerActivate(Sender: TObject);
begin
//* Must be sure SaveAsTemplate is set to false so the internal save
dialog
//* does not show as we will save the report ourself in the
//* frmQueryEditor.actSaveChangesExecute event
ppReport1.SaveAsTemplate := False;
end;
Any ideas how aReport.SaveAsTemplate changed from False to True?
Thanks
If you are loading templates, you need to be sure that this property is
saved as false when you create them. Once you load a template into a report
object, the report properties you set at design time are overridden by the
template settings. If it's too much trouble to open each template at design
time to check this property and resave it back down, the method you are
using below is probably your best solution.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com