* Allow drag&drop of report files.

git-svn-id: trunk@57586 -
This commit is contained in:
michael 2018-03-31 20:15:19 +00:00
parent e2b698c85d
commit c41bb75f54
4 changed files with 37 additions and 3 deletions

View File

@ -33,6 +33,8 @@ Const
rdoAllowNew = frmfpreportdesignermain.rdoAllowNew; // Allow user to start new report
rdoAllowPreview = frmfpreportdesignermain.rdoAllowPreview; // Allow user to ask report preview
rdoAllowBands = frmfpreportdesignermain.rdoAllowBands; // Allow user to add/remove bands
rdoAllowFileDrop = frmfpreportdesignermain.rdoAllowFileDrop; // Allow files to be dropped on designer
type
TFPReportDesignOption = frmfpreportdesignermain.TFPReportDesignOption;

View File

@ -16,6 +16,7 @@ object FPReportDesignerForm: TFPReportDesignerForm
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnDestroy = FormDestroy
OnDropFiles = FormDropFiles
OnKeyPress = FormKeyPress
OnShow = FormShow
SessionProperties = 'FOI.Width;Width;Top;Left;Height'

View File

@ -33,7 +33,8 @@ type
rdoAllowPageAdd, // Allow user to add pages
rdoAllowNew, // Allow user to start new report
rdoAllowPreview, // Allow user to ask report preview
rdoAllowBands // Allow user to add/remove bands
rdoAllowBands, // Allow user to add/remove bands
rdoAllowFileDrop // Allow user to drop files on designer, so they will be loaded.
);
TFPReportDesignOptions = set of TFPReportDesignOption;
@ -275,6 +276,7 @@ type
procedure AResizeExecute(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormDestroy(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
procedure FormShow(Sender: TObject);
procedure PCReportChange(Sender: TObject);
procedure VResizeAllow(Sender: TObject);
@ -390,7 +392,7 @@ type
Const
AllReportDesignOptions = [rdoManageData,rdoManageVariables,rdoAllowLoad,rdoAllowSave,rdoAllowProperties,
rdoAllowPageAdd,rdoAllowNew, rdoAllowPreview, rdoAllowBands];
rdoAllowPageAdd,rdoAllowNew, rdoAllowPreview, rdoAllowBands,rdoAllowFileDrop];
implementation
@ -558,10 +560,39 @@ begin
FreeAndNil(FReportDesignData);
end;
procedure TFPReportDesignerForm.FormDropFiles(Sender: TObject; const FileNames: array of String);
Type
TFPReportDesignerFormClass = Class of TFPReportDesignerForm;
Var
C : TFPReportDesignerFormClass;
F : TFPReportDesignerForm;
I : Integer;
begin
if not (rdoAllowFileDrop in DesignOptions) then exit;
if Length(FileNames)<1 then exit;
if not CheckSaved(SOpenReport) then
exit;
StopDesigning;
LoadReportFromFile(FileNames[0]);
DesignReport;
C:=TFPReportDesignerFormClass(Self.Classtype);
For I:=1 to Length(FileNames)-1 do
begin
F:=C.Create(Application);
F.InitialFileName:=Filenames[i];
F.Show;
end;
end;
procedure TFPReportDesignerForm.FormShow(Sender: TObject);
begin
if rdoAllowFileDrop in DesignOptions then
AllowDropFiles:=True;
CheckLoadInitialFile;
SBReport.Refresh;
end;

View File

@ -276,7 +276,7 @@ begin
F:=TFPReportDesigner.Create(Application);
try
F.Report:=Self.Report;
F.Options:=AllReportDesignOptions-[rdoManageData];
F.Options:=AllReportDesignOptions-[rdoManageData,rdoAllowFileDrop];
F.ModalWindow:=True;
F.Execute;
F.Report.ClearPreparedReport;