Changeset 59 for trunk/UCore.pas
- Timestamp:
- Nov 16, 2012, 9:59:56 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r58 r59 11 11 12 12 type 13 TChronisPlatform = class; 13 14 14 15 { TCore } 15 16 16 17 TCore = class(TDataModule) 17 ApplicationInfo1: TApplicationInfo;18 18 CoolTranslator1: TCoolTranslator; 19 19 Database: TSqlDatabase; … … 23 23 procedure ModuleManagerUpdate(Sender: TObject); 24 24 private 25 FRegistryContext: TRegistryContext; 26 procedure SetRegistryContext(AValue: TRegistryContext); 25 27 public 28 Platform: TChronisPlatform; 26 29 FormModuleList: TFormModuleList; 27 30 FormList: TForm; 28 31 PersistentForm: TPersistentForm; 29 RegistryContext: TRegistryContext;30 32 procedure Init; 31 33 procedure Done; … … 34 36 procedure LoadFromRegistry(AContext: TRegistryContext); 35 37 procedure SaveToRegistry(AContext: TRegistryContext); 38 property RegistryContext: TRegistryContext read FRegistryContext 39 write SetRegistryContext; 36 40 end; 37 41 … … 39 43 40 44 TChronisPlatform = class(TComponent) 45 private 46 FOnRegisterModules: TNotifyEvent; 47 FOnUnregisterModules: TNotifyEvent; 48 FRegistryContext: TRegistryContext; 49 procedure SetRegistryContext(AValue: TRegistryContext); 41 50 public 42 51 constructor Create(AOwner: TComponent); override; … … 44 53 procedure Init; 45 54 procedure Done; 55 property RegistryContext: TRegistryContext read FRegistryContext 56 write SetRegistryContext; 57 published 58 property OnRegisterModules: TNotifyEvent read FOnRegisterModules 59 write FOnRegisterModules; 60 property OnUnregisterModules: TNotifyEvent read FOnUnregisterModules 61 write FOnUnregisterModules; 46 62 end; 47 63 … … 56 72 57 73 uses 58 UFormMain, UFormConnection ;74 UFormMain, UFormConnection, UFormSetting; 59 75 60 76 procedure Register; … … 65 81 { TChronisPlatform } 66 82 83 procedure TChronisPlatform.SetRegistryContext(AValue: TRegistryContext); 84 begin 85 if FRegistryContext = AValue then Exit; 86 FRegistryContext := AValue; 87 if Assigned(Core) then Core.RegistryContext := AValue; 88 end; 89 67 90 constructor TChronisPlatform.Create(AOwner: TComponent); 68 91 begin … … 78 101 begin 79 102 Application.CreateForm(TCore, Core); 80 Application.CreateForm(TFormMain, FormMain); 103 Core.Platform := Self; 104 Core.RegistryContext := FRegistryContext; 105 Application.CreateForm(TFormMain, FormMain); // first form 81 106 Application.CreateForm(TFormConnection, FormConnection); 107 Application.CreateForm(TFormSetting, FormSetting); 82 108 //Core := TCore.Create(Application); 83 109 //FormMain := TFormMain.Create(Application); … … 87 113 procedure TChronisPlatform.Done; 88 114 begin 89 FormConnection.Free; 90 FormMain.Free; 91 Core.Free; 115 (* FreeAndNil(FormSetting); 116 FreeAndNil(FormConnection); 117 FreeAndNil(FormMain); 118 FreeAndNil(Core); *) 92 119 end; 93 120 … … 98 125 begin 99 126 PersistentForm := TPersistentForm.Create; 100 PersistentForm.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot),101 ApplicationInfo1.RegistryKey + '\Forms');102 RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey);103 127 end; 104 128 … … 113 137 FormModuleList.Reload; 114 138 FormMain.ReloadPages; 139 end; 140 141 procedure TCore.SetRegistryContext(AValue: TRegistryContext); 142 begin 143 if (FRegistryContext.RootKey = AValue.RootKey) and 144 (FRegistryContext.Key = AValue.Key) then Exit; 145 FRegistryContext := AValue; 146 PersistentForm.RegistryContext := RegContext(RegistryContext.RootKey, 147 RegistryContext.Key + '\Forms'); 115 148 end; 116 149 … … 126 159 try 127 160 Context := RegistryContext; 128 //RegisterModules(ModuleManager); 161 if Assigned(Platform.OnRegisterModules) then 162 Platform.OnRegisterModules(Self); 129 163 if ReadBoolWithDefault('ModuleManagerInstalled', False) then 130 164 ModuleManager.LoadFromRegistry(RegContext(RegistryContext.RootKey, RegistryContext.Key + '\Modules')) … … 151 185 if Assigned(FormModuleList) then FreeAndNil(FormModuleList); 152 186 ModuleManager.OnUpdate := nil; 153 //UnregisterModules(ModuleManager); 187 if Assigned(Platform.OnUnregisterModules) then 188 Platform.OnUnregisterModules(Self); 154 189 end; 155 190
Note:
See TracChangeset
for help on using the changeset viewer.