@@ -19,7 +19,7 @@ interface
19
19
20
20
uses
21
21
// Project
22
- FirstRun.UConfigFile, FirstRun.UDatabase, FirstRun.UInstallInfo;
22
+ FirstRun.UConfigFile, FirstRun.UDatabase, FirstRun.UInstallInfo, UVersionInfo ;
23
23
24
24
25
25
type
@@ -79,8 +79,17 @@ TFirstRun = class(TObject)
79
79
// / <summary>Creates a new, empty, Unicode encoded per-user config file for
80
80
// / current installation.</summary>
81
81
procedure CreateEmptyUserCfgFile ;
82
- // / <summary>
82
+ // / <summary>Checks if the program has been updated since the last run.
83
+ // / </summary>
84
+ // / <remarks>Compares the version number stored in the brought forward
85
+ // / config file against the current program version number from resources.
86
+ // / </remarks>
83
87
function IsProgramUpdated : Boolean;
88
+ // / <summary>Checks if the previous program's version number, as specified
89
+ // / in the user config file, is contained in the range Lo..Hi with range
90
+ // / endpoints determined by IntervalEndPoints.</summary>
91
+ function IsPreviousProgramVerInRange (const Lo, Hi: TVersionNumber;
92
+ const IntervalEndPoints: TVersionNumber.TIntervalEndPoints): Boolean;
84
93
end ;
85
94
86
95
type
@@ -108,7 +117,8 @@ TFirstRunMgr = class(TObject)
108
117
class function IsProgramUpdated : Boolean;
109
118
public
110
119
// / <summary>Runs start-up checks to detect if program has been run before
111
- // / and performs any required user config and user database updates.
120
+ // / and performs any required user config and user database updates. In
121
+ // / some circumstances a "what's new" dialogue box may be displayed.
112
122
// / </summary>
113
123
class procedure Execute ;
114
124
end ;
@@ -119,9 +129,10 @@ implementation
119
129
120
130
uses
121
131
// Delphi
122
- SysUtils, IOUtils, Forms
123
- { $IFNDEF PORTABLE}
132
+ SysUtils, IOUtils, Forms,
124
133
// Project
134
+ FirstRun.FmWhatsNew
135
+ { $IFNDEF PORTABLE}
125
136
,
126
137
FirstRun.FmV4ConfigDlg;
127
138
{ $ELSE}
@@ -187,6 +198,15 @@ function TFirstRun.HaveOldUserDB: Boolean;
187
198
Result := TFile.Exists(fInstallInfo.PreviousUserDatabaseFileName, False);
188
199
end ;
189
200
201
+ function TFirstRun.IsPreviousProgramVerInRange (const Lo, Hi: TVersionNumber;
202
+ const IntervalEndPoints: TVersionNumber.TIntervalEndPoints): Boolean;
203
+ var
204
+ PrevProgVer: TVersionNumber;
205
+ begin
206
+ PrevProgVer := fUserConfigFile.PreviousProgramVer;
207
+ Result := PrevProgVer.IsInRange(Lo, Hi, IntervalEndPoints);
208
+ end ;
209
+
190
210
function TFirstRun.IsProgramUpdated : Boolean;
191
211
begin
192
212
Result := fUserConfigFile.IsCurrentProgramVer;
@@ -270,6 +290,12 @@ procedure TFirstRun.UpdateUserCfgFile(out Changes: TFirstRunCfgChangeSet);
270
290
{ TFirstRunMgr }
271
291
272
292
class procedure TFirstRunMgr.Execute ;
293
+ const
294
+ // Version numbers specifying a range in which previous program version must
295
+ // lie in order to display "What's New" dialogue box.
296
+ // Range is [NeedWhatsNewLoVerIncl, NeedWhatsNewHiVerExcl)
297
+ NeedWhatsNewLoVerIncl: TVersionNumber = (V1: 4 ; V2: 0 ; V3: 0 ; V4: 0 );
298
+ NeedWhatsNewHiVerExcl: TVersionNumber = (V1: 4 ; V2: 16 ; V3: 0 ; V4: 0 );
273
299
var
274
300
FR: TFirstRun;
275
301
Changes: TFirstRunCfgChangeSet;
@@ -295,7 +321,15 @@ class procedure TFirstRunMgr.Execute;
295
321
begin
296
322
FR := TFirstRun.Create;
297
323
try
298
- FR.UpdateUserCfgFile(Changes);
324
+ // We display "What's New" dialogue box if previous program version number
325
+ // is in the given range
326
+ if FR.IsPreviousProgramVerInRange(
327
+ NeedWhatsNewLoVerIncl,
328
+ NeedWhatsNewHiVerExcl,
329
+ TVersionNumber.TIntervalEndPoints.iepHalfOpenHi
330
+ ) then
331
+ TWhatsNewDlg.Execute(Application);
332
+ FR.UpdateUserCfgFile(Changes); // we ignore Changes [out] param value
299
333
finally
300
334
FR.Free;
301
335
end ;
0 commit comments