From: Jens F. <jfu...@us...> - 2004-06-27 21:42:35
|
Update of /cvsroot/jvcl/dev/JVCL3/examples/JvAppStorage/SubStorage Example In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13563/JVCL3/examples/JvAppStorage/SubStorage Example Added Files: AppStorageExample3.ini AppStorageExample3.xml JvAppStoreDemo.cfg JvAppStoreDemo.dof JvAppStoreDemo.dpr JvAppStoreDemo.res MainForm.dfm MainForm.pas Log Message: AppStorage Example from Salvatore Besso --- NEW FILE: JvAppStoreDemo.cfg --- -$A8 -$B- -$C+ -$D+ -$E- -$F- -$G+ -$H+ -$I+ -$J- -$K- -$L+ -$M- -$N+ -$O+ -$P+ -$Q- -$R- -$S- -$T- -$U- -$V+ -$W- -$X+ -$YD -$Z1 -cg -AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; -H+ -W+ -M -$M16384,1048576 -K$00400000 -LE"d:\programme\entwicklung\borland\delphi7\Projects\Bpl" -LN"d:\programme\entwicklung\borland\delphi7\Projects\Bpl" -w-UNSAFE_TYPE -w-UNSAFE_CODE -w-UNSAFE_CAST --- NEW FILE: AppStorageExample3.ini --- [General] ListBox1Selected=4 FormVersion=0 ShowCmd=1 Flags=0 PixelsPerInch=96 MinMaxPos=-1,-1,-3,-3 NormPos=321,227,721,656 Visible=0 Option1_Checked=False YetAnotherOption1_Checked=False AnotherOptiopn1_Checked=True OpenDialog1_InitialDir= OpenDialog1_FileName= [MinMaxPos] (1280x1024)=-1,-1,-3,-3 [NormPos] (1280x1024)=321,227,721,656 [Memo2_Lines] Count=11 Item0=In addition to storing just component properties for the user, a programmer can Item1=treat the TjvAppStorage like a filesystem or even a database. Values can be Item2=associated with a path and retrieved or written as desired. Item3= Item4=This can be useful for configuration data, stateful data which may not be Item5=published such as selection information, or even just simple datasets. Item6= Item7=This example also demonstrates how the appstorage component can be linked Item8=to the registry, an XML file, or an INI file. Using only the path information the Item9=correct storage facility is used. Item10= --- NEW FILE: JvAppStoreDemo.dof --- [FileVersion] Version=7.0 [Compiler] A=8 B=0 C=1 D=1 E=0 F=0 G=1 H=1 I=1 J=0 K=0 L=1 M=0 N=1 O=1 P=1 Q=0 R=0 S=0 T=0 U=0 V=1 W=0 X=1 Y=1 Z=1 ShowHints=1 ShowWarnings=1 UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; NamespacePrefix= SymbolDeprecated=1 SymbolLibrary=1 SymbolPlatform=1 UnitLibrary=1 UnitPlatform=1 UnitDeprecated=1 HResultCompat=1 HidingMember=1 HiddenVirtual=1 Garbage=1 BoundsError=1 ZeroNilCompat=1 StringConstTruncated=1 ForLoopVarVarPar=1 TypedConstVarPar=1 AsgToTypedConst=1 CaseLabelRange=1 ForVariable=1 ConstructingAbstract=1 ComparisonFalse=1 ComparisonTrue=1 ComparingSignedUnsigned=1 CombiningSignedUnsigned=1 UnsupportedConstruct=1 FileOpen=1 FileOpenUnitSrc=1 BadGlobalSymbol=1 DuplicateConstructorDestructor=1 InvalidDirective=1 PackageNoLink=1 PackageThreadVar=1 ImplicitImport=1 HPPEMITIgnored=1 NoRetVal=1 UseBeforeDef=1 ForLoopVarUndef=1 UnitNameMismatch=1 NoCFGFileFound=1 MessageDirective=1 ImplicitVariants=1 UnicodeToLocale=1 LocaleToUnicode=1 ImagebaseMultiple=1 SuspiciousTypecast=1 PrivatePropAccessor=1 UnsafeType=0 UnsafeCode=0 UnsafeCast=0 [Linker] MapFile=0 OutputObjs=0 ConsoleApp=1 DebugInfo=0 RemoteSymbols=0 MinStackSize=16384 MaxStackSize=1048576 ImageBase=4194304 ExeDescription= [Directories] OutputDir= UnitOutputDir= PackageDLLOutputDir= PackageDCPOutputDir= SearchPath= Packages= Conditionals= DebugSourceDirs= UsePackages=0 [Parameters] RunParams= HostApplication= Launcher= UseLauncher=0 DebugCWD= [Language] ActiveLang= ProjectLang= RootDir= [Version Info] IncludeVerInfo=0 AutoIncBuild=0 MajorVer=1 MinorVer=0 Release=0 Build=0 Debug=0 PreRelease=0 Special=0 Private=0 DLL=0 Locale=1033 CodePage=1252 [Version Info Keys] CompanyName= FileDescription= FileVersion=1.0.0.0 InternalName= LegalCopyright= LegalTrademarks= OriginalFilename= ProductName= ProductVersion=1.0.0.0 Comments= [HistoryLists\hlUnitAliases] Count=1 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; [HistoryLists\hlUnitOutputDirectory] Count=1 Item0=..\dcus [HistoryLists\hlOutputDirectorry] Count=1 Item0=..\bin --- NEW FILE: MainForm.pas --- unit MainForm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, JvAppXMLStorage, JvFormPlacementSelectList, JvFormPlacement, JvAppDBStorage, JvAppStorageSelectList, JvAppStorage, JvAppIniStorage, JvComponent, JvAppRegistryStorage, ExtCtrls, ComCtrls, ToolWin, StdCtrls, ShellAPI, Menus, jvDynControlEngine, jvDynControlEngineJVCL; type TMainFormDlg = class(TForm) StatusBar1: TStatusBar; JvAppIniFileStorage1: TJvAppIniFileStorage; JvFormStorage1: TJvFormStorage; PopupMenu1: TPopupMenu; AnotherOptiopn1: TMenuItem; YetAnotherOption1: TMenuItem; Option1: TMenuItem; Panel1: TPanel; Panel3: TPanel; Memo2: TMemo; Label2: TLabel; OpenDialog1: TOpenDialog; JvFormStorageSelectList1: TJvFormStorageSelectList; ToolBar1: TToolBar; ToolButton1: TToolButton; ToolButton2: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; JvAppXMLFileStorage1: TJvAppXMLFileStorage; JvAppRegistryStorage1: TJvAppRegistryStorage; JvAppStorage1: TJvAppStorage; Panel2: TPanel; Label1: TLabel; rbXML: TRadioButton; rbReg: TRadioButton; rbINI: TRadioButton; Edit1: TEdit; Button1: TButton; ListBox1: TListBox; Label3: TLabel; procedure YetAnotherOption1Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure jvStorageKindClick(Sender: TObject); procedure JvFormStorage1RestorePlacement(Sender: TObject); private procedure CheckStorageKind; protected procedure loaded; override; { Private declarations } public { Public declarations } StoragePath: String; end; var MainFormDlg: TMainFormDlg; implementation {$R *.dfm} procedure TMainFormDlg.YetAnotherOption1Click(Sender: TObject); begin if Sender is TMenuItem then TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked; end; procedure TMainFormDlg.ToolButton1Click(Sender: TObject); begin JvFormStorage1.SaveFormPlacement; end; procedure TMainFormDlg.ToolButton2Click(Sender: TObject); begin JvFormStorage1.RestoreFormPlacement; end; procedure TMainFormDlg.Button1Click(Sender: TObject); var FormStorageSelectList: tJvFormStorageSelectList; begin FormStorageSelectList := tJvFormStorageSelectList.Create(Self); try FormStorageSelectList.FormStorage := JvFormStorage1; FormStorageSelectList.AppStorage := JvAppINIFileStorage1; FormStorageSelectList.SelectPath := 'SelectTest'; FormStorageSelectList.RestoreFormStorage; finally FormStorageSelectList.Free; end; end; procedure TMainFormDlg.Button2Click(Sender: TObject); var FormStorageSelectList: tJvFormStorageSelectList; begin FormStorageSelectList := tJvFormStorageSelectList.Create(Self); try FormStorageSelectList.FormStorage := JvFormStorage1; FormStorageSelectList.AppStorage := JvAppINIFileStorage1; FormStorageSelectList.SelectPath := 'SelectTest'; FormStorageSelectList.SaveFormStorage; finally FormStorageSelectList.Free; end; end; procedure TMainFormDlg.ToolButton5Click(Sender: TObject); begin jvAppStorage1.WriteInteger(StoragePath+'ListBox1Selected', ListBox1.ItemIndex); end; procedure TMainFormDlg.ToolButton6Click(Sender: TObject); begin ListBox1.ItemIndex := jvAppStorage1.ReadInteger(StoragePath+'ListBox1Selected', 0); end; procedure TMainFormDlg.CheckStorageKind; begin if rbXML.Checked then StoragePath := '\XML\'; if rbINI.Checked then StoragePath := '\INI\'; if rbReg.Checked then StoragePath := '\REG\'; jvFormStorage1.AppStoragePath := StoragePath; end; procedure TMainFormDlg.jvStorageKindClick(Sender: TObject); begin CheckStorageKind; end; procedure TMainFormDlg.JvFormStorage1RestorePlacement(Sender: TObject); begin CheckStorageKind; // here is an excellent place to restore values for a form if they // are the sort of properties that are not published, such as // selection values etc... end; procedure TMainFormDlg.loaded; begin CheckStorageKind; end; end. --- NEW FILE: MainForm.dfm --- object MainFormDlg: TMainFormDlg Left = 321 Top = 227 BorderStyle = bsDialog Caption = 'AppStorage Example #3' ClientHeight = 397 ClientWidth = 394 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object StatusBar1: TStatusBar Left = 0 Top = 378 Width = 394 Height = 19 Panels = <> end object Panel1: TPanel Left = 0 Top = 73 Width = 394 Height = 305 Align = alClient TabOrder = 1 object Panel3: TPanel Left = 1 Top = 138 Width = 392 Height = 166 Align = alClient BevelOuter = bvSpace Caption = 'Panel3' TabOrder = 0 object Label2: TLabel Left = 1 Top = 1 Width = 390 Height = 13 Align = alTop Caption = 'Stored Memo:' end object Memo2: TMemo Left = 1 Top = 14 Width = 390 Height = 151 Align = alClient Lines.Strings = ( 'In addition to storing just component properties for the user, a' + ' programmer can ' 'treat the TjvAppStorage like a filesystem or even a database. Va' + 'lues can be ' 'associated with a path and retrieved or written as desired. ' '' 'This can be useful for configuration data, stateful data which m' + 'ay not be ' 'published such as selection information, or even just simple dat' + 'asets. ' '' 'This example also demonstrates how the appstorage component can ' + 'be linked ' 'to the registry, an XML file, or an INI file. Using only the pat' + 'h information the ' 'correct storage facility is used.' '') TabOrder = 0 end end object Panel2: TPanel Left = 1 Top = 1 Width = 392 Height = 137 Align = alTop BevelInner = bvLowered BevelOuter = bvNone TabOrder = 1 object Label1: TLabel Left = 8 Top = 12 Width = 55 Height = 13 Caption = 'Stored Edit:' end object Label3: TLabel Left = 40 Top = 48 Width = 61 Height = 13 Caption = 'Storage Kind' end object rbXML: TRadioButton Left = 38 Top = 63 Width = 113 Height = 17 Caption = 'XML File' Checked = True TabOrder = 0 TabStop = True OnClick = jvStorageKindClick end object rbReg: TRadioButton Left = 38 Top = 79 Width = 113 Height = 17 Caption = 'Registry' TabOrder = 1 OnClick = jvStorageKindClick end object rbINI: TRadioButton Left = 38 Top = 95 Width = 113 Height = 17 Caption = 'INI File' TabOrder = 2 OnClick = jvStorageKindClick end object Edit1: TEdit Left = 64 Top = 8 Width = 121 Height = 21 TabOrder = 3 Text = 'Some Value' end object Button1: TButton Left = 168 Top = 96 Width = 73 Height = 25 Caption = 'Open Dialog' TabOrder = 4 end object ListBox1: TListBox Left = 248 Top = 16 Width = 121 Height = 105 ItemHeight = 13 Items.Strings = ( 'Item 1' 'Item 2' 'Item 3' 'Item 4' 'Item 5' 'Item 6') TabOrder = 5 end end end object ToolBar1: TToolBar Left = 0 Top = 0 Width = 394 Height = 73 AutoSize = True BorderWidth = 2 ButtonHeight = 21 ButtonWidth = 148 Caption = 'ToolBar1' EdgeBorders = [] EdgeInner = esNone EdgeOuter = esNone ShowCaptions = True TabOrder = 2 object ToolButton1: TToolButton Left = 0 Top = 2 Caption = 'Save Form Values' ImageIndex = 0 OnClick = ToolButton1Click end object ToolButton2: TToolButton Left = 148 Top = 2 Caption = 'Load Form Values' ImageIndex = 1 Wrap = True OnClick = ToolButton2Click end object ToolButton4: TToolButton Left = 0 Top = 23 Caption = 'Save Values By Name To List' ImageIndex = 3 OnClick = Button2Click end object ToolButton3: TToolButton Left = 148 Top = 23 Caption = 'Select Values From List' ImageIndex = 2 Wrap = True OnClick = Button1Click end object ToolButton5: TToolButton Left = 0 Top = 44 Caption = 'Save ListBox Select Value' ImageIndex = 4 OnClick = ToolButton5Click end object ToolButton6: TToolButton Left = 148 Top = 44 Caption = 'Load ListBox Select Value' ImageIndex = 5 OnClick = ToolButton6Click end end object JvAppIniFileStorage1: TJvAppIniFileStorage StorageOptions.BooleanStringTrueValues = 'TRUE, YES, Y' StorageOptions.BooleanStringFalseValues = 'FALSE, NO, N' FileName = 'AppStorageExample3.xml' DefaultSection = 'General' SubStorages = <> Left = 304 Top = 190 end object JvFormStorage1: TJvFormStorage AppStorage = JvAppStorage1 OnRestorePlacement = JvFormStorage1RestorePlacement StoredProps.Strings = ( 'Option1.Checked' 'YetAnotherOption1.Checked' 'AnotherOptiopn1.Checked' 'OpenDialog1.InitialDir' 'OpenDialog1.FileName' 'Memo2.Lines') StoredValues = <> Left = 203 Top = 83 end object PopupMenu1: TPopupMenu Left = 169 Top = 135 object Option1: TMenuItem Caption = 'Option' OnClick = YetAnotherOption1Click end object AnotherOptiopn1: TMenuItem Caption = 'Another Option' Checked = True OnClick = YetAnotherOption1Click end object YetAnotherOption1: TMenuItem Caption = 'Yet Another Option' OnClick = YetAnotherOption1Click end end object OpenDialog1: TOpenDialog Left = 8 Top = 120 end object JvFormStorageSelectList1: TJvFormStorageSelectList AppStorage = JvAppStorage1 SelectPath = 'something' FormStorage = JvFormStorage1 Left = 110 Top = 101 end object JvAppXMLFileStorage1: TJvAppXMLFileStorage StorageOptions.BooleanStringTrueValues = 'TRUE, YES, Y' StorageOptions.BooleanStringFalseValues = 'FALSE, NO, N' FileName = 'AppStorageExample3.xml' RootNodeName = 'Configuration' SubStorages = <> Left = 304 Top = 143 end object JvAppRegistryStorage1: TJvAppRegistryStorage StorageOptions.BooleanStringTrueValues = 'TRUE, YES, Y' StorageOptions.BooleanStringFalseValues = 'FALSE, NO, N' Root = 'Software\JVCL\JvAppStorageDemo3' SubStorages = <> Left = 304 Top = 96 end object JvAppStorage1: TJvAppStorage StorageOptions.BooleanStringTrueValues = 'TRUE, YES, Y' StorageOptions.BooleanStringFalseValues = 'FALSE, NO, N' SubStorages = < item RootPath = 'XML' AppStorage = JvAppXMLFileStorage1 end item RootPath = 'REG' AppStorage = JvAppRegistryStorage1 end item RootPath = 'INI' AppStorage = JvAppIniFileStorage1 end> Left = 200 Top = 136 end end --- NEW FILE: JvAppStoreDemo.dpr --- program JvAppStoreDemo; uses Forms, MainForm in 'MainForm.pas' {MainFormDlg}; {$R *.res} begin Application.Initialize; Application.CreateForm(TMainFormDlg, MainFormDlg); Application.Run; end. --- NEW FILE: AppStorageExample3.xml --- [General] ListBox1Selected=-1 FormVersion=0 ShowCmd=1 Flags=0 PixelsPerInch=96 MinMaxPos(1280x1024)=-1,-1,-3,-3 MinMaxPos=-1,-1,-3,-3 NormPos(1280x1024)=321,227,721,656 NormPos=321,227,721,656 Visible=0 Option1_Checked=False YetAnotherOption1_Checked=False AnotherOptiopn1_Checked=True OpenDialog1_InitialDir= OpenDialog1_FileName= [Memo2_Lines] Count=11 Item0=In addition to storing just component properties for the user, a programmer can Item1=treat the TjvAppStorage like a filesystem or even a database. Values can be Item2=associated with a path and retrieved or written as desired. Item3= Item4=This can be useful for configuration data, stateful data which may not be Item5=published such as selection information, or even just simple datasets. Item6= Item7=This example also demonstrates how the appstorage component can be linked Item8=to the registry, an XML file, or an INI file. Using only the path information the Item9=correct storage facility is used. Item10= --- NEW FILE: JvAppStoreDemo.res --- (This appears to be a binary file; contents omitted.) |