Skip to content

Commit b49abba

Browse files
delphi: Update and clarify the example
- Use correct terms: import (open) a report layout, save a report layout. - Title the file open dialog 'Import Report Layout'. - Title the file save dialog 'Save Report Layout'. - Assign proper name, icon, and title to the application. - Display the currently opened report in the application title. - Extract a method to load a report and update the application caption. - Before saving a report, pass the name to the file save dialog. - Clarify error messages in message boxes. - Fix the SQLite connection string: correct path to nwind.db. Co-authored-by: Ilia Nenashev <ilia.nenashev@devexpress.com>
1 parent 3bb95ef commit b49abba

6 files changed

Lines changed: 109 additions & 92 deletions

File tree

Delphi/ReportStoreToFile.dpr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ uses
1010
begin
1111
Application.Initialize;
1212
Application.MainFormOnTaskbar := True;
13+
Application.Title := 'DevExpress Example';
1314
Application.CreateForm(TMainForm, MainForm);
1415
Application.Run;
1516
end.

Delphi/ReportStoreToFile.dproj

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
33
<ProjectGuid>{FFE68CA0-DDFE-4451-A27A-29E2BFE7706F}</ProjectGuid>
44
<ProjectVersion>20.3</ProjectVersion>
@@ -82,6 +82,8 @@
8282
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
8383
<PostBuildEvent><![CDATA[copy /Y "$(BDS)\Redist\win32\WebView2Loader.dll" $(OUTPUTDIR)
8484
$(PostBuildEvent)]]></PostBuildEvent>
85+
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
86+
<Icon_MainIcon>ReportStoreToFile_Icon.ico</Icon_MainIcon>
8587
</PropertyGroup>
8688
<PropertyGroup Condition="'$(Base_Win64)'!=''">
8789
<DCC_UsePackage>dxPScxCommonRS29;dxPSdxChartControlLnkRS29;dxRibbonRS29;vclwinx;DataSnapServer;dxPScxExtCommonRS29;dxRichEditControlCoreRS29;fmx;dxSpreadSheetReportDesignerRS29;vclie;DbxCommonDriver;bindengine;IndyIPCommon;VCLRESTComponents;DBXMSSQLDriver;FireDACCommonODBC;emsclient;dxComnRS29;dxFlowChartDesignerRS29;appanalytics;IndyProtocols;vclx;dxBarExtDBItemsRS29;dbxcds;vcledge;cxVerticalGridRS29;FmxTeeUI;cxFireDACAdaptersRS29;dxPSDBTeeChartRS29;cxSchedulerWebServiceStorageRS29;DBXFirebirdDriver;dxRichEditControlRS29;dxPsPrVwAdvRS29;FireDACSqliteDriver;DbxClientDriver;dxPSdxGaugeControlLnkRS29;soapmidas;dxRibbonCustomizationFormRS29;TeeUI;dbexpress;dxEMFRS29;dxDockingRS29;inet;vcltouch;dxPSdxFCLnkRS29;dxorgcRS29;FireDACDBXDriver;dxSpreadSheetCoreConditionalFormattingDialogsRS29;fmxdae;dxPSRichEditControlLnkRS29;dxPSdxSpreadSheetLnkRS29;CustomIPTransport;FireDACMSSQLDriver;cxADOAdaptersRS29;dxPSPrVwRibbonRS29;IndySystem;dxPScxTLLnkRS29;dxPSdxDBOCLnkRS29;dxGDIPlusRS29;ibxbindings;vclFireDAC;dxPSCoreRS29;dxSpreadSheetRS29;FireDACCommon;DataSnapServerMidas;FireDACODBCDriver;emsserverresource;cxGridEMFRS29;dxPSdxMapControlLnkRS29;dxGanttControlRS29;dxPScxVGridLnkRS29;dxPScxPivotGridLnkRS29;dxWizardControlRS29;dxADOServerModeRS29;bindcompdbx;rtl;FireDACMySQLDriver;dxCloudServiceLibraryRS29;cxIBXAdaptersRS29;dxServerModeRS29;DBXSqliteDriver;dxBarDBNavRS29;DBXSybaseASEDriver;dxSpreadSheetCoreRS29;dxNavBarRS29;vclimg;DataSnapFireDAC;inetdbxpress;FireDAC;xmlrtl;ibxpress;dxFireDACEMFRS29;dsnap;FireDACDb2Driver;dxPSdxLCLnkRS29;DBXOracleDriver;DBXInformixDriver;vclib;fmxobj;bindcompvclsmp;DataSnapNativeClient;DatasnapConnectorsFreePascal;dxPSLnksRS29;dxmdsRS29;dxPSdxOCLnkRS29;cxSchedulerGridRS29;dxPScxSchedulerLnkRS29;emshosting;dxADOEMFRS29;dxChartControlRS29;dxPSdxDBTVLnkRS29;FireDACCommonDriver;dxGaugeControlRS29;IndyIPClient;dxPDFViewerRS29;bindcompvclwinx;dxOrgChartAdvancedCustomizeFormRS29;emsedge;bindcompfmx;dxBarExtItemsRS29;dxReportsRS29;dxFlowChartLayoutsRS29;inetdb;dxdborRS29;ibmonitor;FireDACASADriver;Tee;dxPScxGridLnkRS29;cxPivotGridChartRS29;vclactnband;fmxFireDAC;FireDACInfxDriver;dxRichEditCoreRS29;cxTreeListdxBarPopupMenuRS29;DBXMySQLDriver;dxFlowChartAdvancedCustomizeFormRS29;VclSmp;cxSchedulerRibbonStyleEventEditorRS29;DataSnapCommon;dxPSTeeChartRS29;fmxase;dxtrmdRS29;dxFlowChartRS29;DBXOdbcDriver;dbrtl;dxPScxPCProdRS29;FireDACOracleDriver;TeeDB;FireDACMSAccDriver;cxGridRS29;dxSpellCheckerRS29;DataSnapIndy10ServerTransport;dxRichEditDocumentModelRS29;dxMapControlRS29;DataSnapConnectors;vcldsnap;DBXInterBaseDriver;FireDACMongoDBDriver;FireDACTDataDriver;cxLibraryRS29;Skia.Package.VCL;vcldb;dxPSdxPDFViewerLnkRS29;cxSchedulerTreeBrowserRS29;bindcomp;dxTabbedMDIRS29;cxExportRS29;inetstn;IndyCore;RESTBackendComponents;dxHttpIndyRequestRS29;dxTileControlRS29;dxFireDACServerModeRS29;cxPivotGridOLAPRS29;FireDACADSDriver;RESTComponents;IndyIPServer;vcl;dsnapxml;adortl;dsnapcon;DataSnapClient;DataSnapProviderClient;dxCoreRS29;cxPivotGridRS29;dxdbtrRS29;DBXDb2Driver;dxSkinsCoreRS29;emsclientfiredac;FireDACPgDriver;FireDACDSDriver;dxBarRS29;tethering;bindcompvcl;CloudService;DBXSybaseASADriver;dxSpreadSheetConditionalFormattingDialogsRS29;cxTreeListRS29;FMXTee;soaprtl;cxSchedulerRS29;dxDBXServerModeRS29;soapserver;FireDACIBDriver;$(DCC_UsePackage)</DCC_UsePackage>
@@ -93,6 +95,8 @@ $(PostBuildEvent)]]></PostBuildEvent>
9395
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
9496
<PostBuildEvent><![CDATA[copy /Y "$(BDS)\Redist\win64\WebView2Loader.dll" $(OUTPUTDIR)
9597
$(PostBuildEvent)]]></PostBuildEvent>
98+
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
99+
<Icon_MainIcon>ReportStoreToFile_Icon.ico</Icon_MainIcon>
96100
</PropertyGroup>
97101
<PropertyGroup Condition="'$(Cfg_1)'!=''">
98102
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
@@ -109,11 +113,13 @@ $(PostBuildEvent)]]></PostBuildEvent>
109113
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
110114
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
111115
<VerInfo_Locale>1033</VerInfo_Locale>
116+
<Icon_MainIcon>ReportStoreToFile_Icon.ico</Icon_MainIcon>
112117
</PropertyGroup>
113118
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
114119
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
115120
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
116121
<VerInfo_Locale>1033</VerInfo_Locale>
122+
<Icon_MainIcon>ReportStoreToFile_Icon1.ico</Icon_MainIcon>
117123
</PropertyGroup>
118124
<PropertyGroup Condition="'$(Cfg_2)'!=''">
119125
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
@@ -157,10 +163,10 @@ $(PostBuildEvent)]]></PostBuildEvent>
157163
<Source Name="MainSource">ReportStoreToFile.dpr</Source>
158164
</Source>
159165
<Excluded_Packages>
160-
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k290.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
161-
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp290.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
162-
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k290.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
163-
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
166+
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k370.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
167+
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp370.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
168+
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k370.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
169+
<Excluded_Packages Name="$(BDSBIN)\dclofficexp370.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
164170
</Excluded_Packages>
165171
</Delphi.Personality>
166172
<Deployment Version="5">
@@ -1136,35 +1142,31 @@ $(PostBuildEvent)]]></PostBuildEvent>
11361142
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
11371143
<PreLinkEvent/>
11381144
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
1139-
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win32\WebView2Loader.dll&quot; $(OUTPUTDIR)
1140-
</PostBuildEvent>
1145+
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win32\WebView2Loader.dll&quot; $(OUTPUTDIR)</PostBuildEvent>
11411146
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
11421147
</PropertyGroup>
11431148
<PropertyGroup Condition="'$(Config)'=='Debug' And '$(Platform)'=='Win64'">
11441149
<PreBuildEvent/>
11451150
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
11461151
<PreLinkEvent/>
11471152
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
1148-
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win64\WebView2Loader.dll&quot; $(OUTPUTDIR)
1149-
</PostBuildEvent>
1153+
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win64\WebView2Loader.dll&quot; $(OUTPUTDIR)</PostBuildEvent>
11501154
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
11511155
</PropertyGroup>
11521156
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Win32'">
11531157
<PreBuildEvent/>
11541158
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
11551159
<PreLinkEvent/>
11561160
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
1157-
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win32\WebView2Loader.dll&quot; $(OUTPUTDIR)
1158-
</PostBuildEvent>
1161+
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win32\WebView2Loader.dll&quot; $(OUTPUTDIR)</PostBuildEvent>
11591162
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
11601163
</PropertyGroup>
11611164
<PropertyGroup Condition="'$(Config)'=='Release' And '$(Platform)'=='Win64'">
11621165
<PreBuildEvent/>
11631166
<PreBuildEventIgnoreExitCode>False</PreBuildEventIgnoreExitCode>
11641167
<PreLinkEvent/>
11651168
<PreLinkEventIgnoreExitCode>False</PreLinkEventIgnoreExitCode>
1166-
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win64\WebView2Loader.dll&quot; $(OUTPUTDIR)
1167-
</PostBuildEvent>
1169+
<PostBuildEvent>copy /Y &quot;$(BDS)\Redist\win64\WebView2Loader.dll&quot; $(OUTPUTDIR)</PostBuildEvent>
11681170
<PostBuildEventIgnoreExitCode>False</PostBuildEventIgnoreExitCode>
11691171
</PropertyGroup>
11701172
</Project>

Delphi/ReportStoreToFile_Icon.ico

26 KB
Binary file not shown.

Delphi/uMainForm.dfm

Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
object MainForm: TMainForm
22
Left = 0
33
Top = 0
4-
Width = 587
5-
Height = 344
4+
Width = 577
5+
Height = 312
66
AutoScroll = True
77
AutoSize = True
88
Caption = 'MainForm'
@@ -21,49 +21,49 @@ object MainForm: TMainForm
2121
Height = 273
2222
TabOrder = 0
2323
AutoSize = True
24-
object btnOpen: TcxButton
25-
Left = 12
26-
Top = 44
24+
CustomizeFormTabbedView = True
25+
object btnImport: TcxButton
26+
Left = 26
27+
Top = 83
2728
Width = 145
2829
Height = 25
29-
Caption = 'Open Report'
30-
SpeedButtonOptions.CanBeFocused = False
30+
Caption = 'Import from File'
3131
TabOrder = 1
32-
OnClick = btnOpenClick
32+
OnClick = btnImportClick
3333
end
3434
object btnPreview: TcxButton
35-
Left = 164
36-
Top = 75
35+
Left = 206
36+
Top = 82
3737
Width = 193
3838
Height = 25
39-
Caption = 'Preview Report'
39+
Caption = 'Open Viewer'
4040
TabOrder = 4
4141
OnClick = btnPreviewClick
4242
end
4343
object btnNew: TcxButton
44-
Left = 12
45-
Top = 12
44+
Left = 26
45+
Top = 51
4646
Width = 145
4747
Height = 25
48-
Caption = 'New Report'
48+
Caption = 'Create New'
4949
TabOrder = 0
5050
OnClick = btnNewClick
5151
end
52-
object btnSave: TcxButton
53-
Left = 164
54-
Top = 12
55-
Width = 193
52+
object btnSaveToFile: TcxButton
53+
Left = 26
54+
Top = 115
55+
Width = 145
5656
Height = 25
57-
Caption = 'Save Report'
57+
Caption = 'Save to File'
5858
TabOrder = 2
59-
OnClick = btnSaveClick
59+
OnClick = btnSaveToFileClick
6060
end
6161
object btnDesign: TcxButton
62-
Left = 164
63-
Top = 44
62+
Left = 206
63+
Top = 51
6464
Width = 193
6565
Height = 24
66-
Caption = 'Design Report'
66+
Caption = 'Open Designer'
6767
TabOrder = 3
6868
OnClick = btnDesignClick
6969
end
@@ -92,21 +92,21 @@ object MainForm: TMainForm
9292
AlignVert = avTop
9393
CaptionOptions.Text = 'btnOpen'
9494
CaptionOptions.Visible = False
95-
Control = btnOpen
95+
Control = btnImport
9696
ControlOptions.OriginalHeight = 25
9797
ControlOptions.OriginalWidth = 145
9898
ControlOptions.ShowBorder = False
9999
Index = 1
100100
end
101101
object liSave: TdxLayoutItem
102-
Parent = dxLayoutGroup2
102+
Parent = dxLayoutGroup1
103103
CaptionOptions.Text = 'btnSave'
104104
CaptionOptions.Visible = False
105-
Control = btnSave
105+
Control = btnSaveToFile
106106
ControlOptions.OriginalHeight = 25
107107
ControlOptions.OriginalWidth = 145
108108
ControlOptions.ShowBorder = False
109-
Index = 0
109+
Index = 2
110110
end
111111
object liDesign: TdxLayoutItem
112112
Parent = dxLayoutGroup2
@@ -116,7 +116,7 @@ object MainForm: TMainForm
116116
ControlOptions.OriginalHeight = 24
117117
ControlOptions.OriginalWidth = 193
118118
ControlOptions.ShowBorder = False
119-
Index = 1
119+
Index = 0
120120
end
121121
object liPreview: TdxLayoutItem
122122
Parent = dxLayoutGroup2
@@ -126,7 +126,7 @@ object MainForm: TMainForm
126126
ControlOptions.OriginalHeight = 25
127127
ControlOptions.OriginalWidth = 193
128128
ControlOptions.ShowBorder = False
129-
Index = 2
129+
Index = 1
130130
end
131131
object dxLayoutLabeledItem1: TdxLayoutLabeledItem
132132
CaptionOptions.Text = 'Label'
@@ -135,53 +135,48 @@ object MainForm: TMainForm
135135
object dxLayoutGroup1: TdxLayoutGroup
136136
Parent = dxLayoutControl1Group_Root
137137
AlignHorz = ahClient
138-
CaptionOptions.Text = 'New Group'
139-
CaptionOptions.Visible = False
138+
CaptionOptions.Text = 'Report Layout'
140139
ItemIndex = 1
141-
ShowBorder = False
142140
Index = 0
143141
end
144142
object dxLayoutGroup2: TdxLayoutGroup
145143
Parent = dxLayoutControl1Group_Root
146-
AlignHorz = ahClient
147-
CaptionOptions.Text = 'New Group'
148-
CaptionOptions.Visible = False
149-
ItemIndex = 2
150-
ShowBorder = False
144+
CaptionOptions.Text = 'Report Dialogs'
151145
Index = 1
152146
end
153147
end
154148
object dxReport1: TdxReport
155149
Parameters = <>
156150
OnLayoutChanged = dxReport1LayoutChanged
157-
Left = 40
158-
Top = 192
151+
Left = 16
152+
Top = 224
159153
end
160154
object dxOpenFileDialog: TdxOpenFileDialog
161155
Filter = 'REPX (*.repx)|*.repx'
162156
Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing]
163-
Left = 160
164-
Top = 144
157+
Title = 'Import Report Layout'
158+
Left = 136
159+
Top = 176
165160
end
166161
object dxSaveFileDialog: TdxSaveFileDialog
167162
DefaultExt = 'repx'
168163
Filter = 'REPX (*.repx)|*.repx'
169-
Left = 96
170-
Top = 144
164+
Title = 'Save Report Layout'
165+
Left = 72
166+
Top = 176
171167
end
172168
object dxBackendDataConnectionManager: TdxBackendDataConnectionManager
173-
Left = 40
174-
Top = 144
169+
Left = 16
170+
Top = 176
175171
object ReportsNWindConnectionString: TdxBackendDatabaseSQLConnection
176172
DisplayName = 'NWindConnectionString'
177-
ConnectionString =
178-
'XpoProvider=SQLite; Data Source=|DataDirectory|\..\..\..\nwind.d' +
179-
'b; Mode=ReadOnly'
173+
ConnectionString = 'XpoProvider=SQLite; Data Source=..\..\..\nwind.db; Mode=ReadOnly'
180174
end
181175
end
182176
object dxSkinController1: TdxSkinController
177+
NativeStyle = False
183178
SkinName = 'WXI'
184-
Left = 96
185-
Top = 192
179+
Left = 72
180+
Top = 224
186181
end
187182
end

0 commit comments

Comments
 (0)