Changeset 15 for trunk/UFormMain.pas
- Timestamp:
- Apr 29, 2016, 12:09:44 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMain.pas
r14 r15 97 97 FoundAcronyms: TAcronymMeanings; 98 98 RegistryContext: TRegistryContext; 99 ProjectClosed: Boolean; 99 100 procedure OpenRecentClick(Sender: TObject); 100 101 procedure UpdateAcronymsList; … … 146 147 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 147 148 begin 148 AFileClose.Execute;149 149 PersistentForm1.Save(Self); 150 150 SaveConfig; … … 152 152 153 153 procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean); 154 begin 155 AFileClose.Execute; 156 CanClose := ProjectClosed; 157 end; 158 159 procedure TFormMain.AExitExecute(Sender: TObject); 160 begin 161 Close; 162 end; 163 164 procedure TFormMain.AFileCloseExecute(Sender: TObject); 154 165 var 155 166 ModalResult: TModalResult; … … 160 171 if ModalResult = mrYes then begin 161 172 AFileSave.Execute; 162 CanClose := True; 173 FreeAndNil(AcronymDb); 174 UpdateAcronymsList; 175 UpdateInterface; 176 ProjectClosed := True; 163 177 end 164 178 else if ModalResult = mrNo then begin 165 CanClose := True; 166 AcronymDb.Modified := False; 167 end else CanClose := False; 168 end; 169 end; 170 171 procedure TFormMain.AExitExecute(Sender: TObject); 172 begin 173 Close; 174 end; 175 176 procedure TFormMain.AFileCloseExecute(Sender: TObject); 177 begin 178 if Assigned(AcronymDb) then begin 179 if AcronymDb.Modified then AFileSave.Execute; 180 FreeAndNil(AcronymDb); 179 FreeAndNil(AcronymDb); 180 UpdateAcronymsList; 181 UpdateInterface; 182 ProjectClosed := True; 183 end else ProjectClosed := False; 184 end else ProjectClosed := True; 185 end; 186 187 procedure TFormMain.AFileNewExecute(Sender: TObject); 188 begin 189 AFileClose.Execute; 190 if ProjectClosed then begin 191 AcronymDb := TAcronymDb.Create; 192 AcronymDb.FileName := DefaultFileName; 193 AcronymDb.Acronyms.Clear; 181 194 UpdateAcronymsList; 182 195 UpdateInterface; 183 196 end; 184 end;185 186 procedure TFormMain.AFileNewExecute(Sender: TObject);187 begin188 AFileClose.Execute;189 AcronymDb := TAcronymDb.Create;190 AcronymDb.FileName := DefaultFileName;191 AcronymDb.Acronyms.Clear;192 UpdateAcronymsList;193 UpdateInterface;194 197 end; 195 198 … … 201 204 if OpenDialog1.Execute then begin 202 205 AFileClose.Execute; 203 AFileNew.Execute; 204 AcronymDb.LoadFromFile(OpenDialog1.FileName); 205 LastOpenedList1.AddItem(OpenDialog1.FileName); 206 UpdateAcronymsList; 207 UpdateInterface; 206 if ProjectClosed then begin 207 AFileNew.Execute; 208 AcronymDb.LoadFromFile(OpenDialog1.FileName); 209 LastOpenedList1.AddItem(OpenDialog1.FileName); 210 UpdateAcronymsList; 211 UpdateInterface; 212 end; 208 213 end; 209 214 end; … … 333 338 begin 334 339 FormCategories.ShowModal; 340 UpdateAcronymsList; 341 UpdateInterface; 335 342 end; 336 343 … … 424 431 begin 425 432 AFileClose.Execute; 426 AFileNew.Execute; 427 AcronymDb.LoadFromFile(TMenuItem(Sender).Caption); 428 LastOpenedList1.AddItem(TMenuItem(Sender).Caption); 429 UpdateAcronymsList; 430 UpdateInterface; 433 if ProjectClosed then begin 434 AFileNew.Execute; 435 AcronymDb.LoadFromFile(TMenuItem(Sender).Caption); 436 LastOpenedList1.AddItem(TMenuItem(Sender).Caption); 437 UpdateAcronymsList; 438 UpdateInterface; 439 end; 431 440 end; 432 441
Note:
See TracChangeset
for help on using the changeset viewer.