unit uConfiguracion; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ActnList, JvComponent, JvAppStorage, JvAppRegistryStorage, Contnrs, ExtCtrls, ImgList, PngImageList, JvExControls, JvGradientHeaderPanel, uFrameConfiguracion, JvComponentBase; type TfConfiguracion = class(TForm) tvArbol: TTreeView; Button1: TButton; Button2: TButton; ActionList1: TActionList; actAceptar: TAction; actCancelar: TAction; JvAppRegistryStorage1: TJvAppRegistryStorage; pnlPagina: TTabControl; PngImageList1: TPngImageList; pnlHeader: TJvGradientHeaderPanel; ListView1: TListView; procedure FormCreate(Sender: TObject); procedure tvArbolChange(Sender: TObject; Node: TTreeNode); procedure actAceptarExecute(Sender: TObject); procedure actCancelarExecute(Sender: TObject); procedure ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); private FPaginaActual : IConfiguracionFrame; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; var fConfiguracion: TfConfiguracion; implementation uses uConexionBD, uDataModuleServer, uConfGeneral; {$R *.dfm} type TFrameClass = class of TFrameConfiguracion; function CreateFrame(Parent: TWinControl; FrameClass: TFrameClass): IConfiguracionFrame; var aFrame : TFrameConfiguracion; begin aFrame := FrameClass.Create(NIL); aFrame.Name:='Frame'+IntToStr(Random(10000)); aFrame.Parent := Parent; aFrame.Init; aFrame.Show; Result := aFrame; end; constructor TfConfiguracion.Create(AOwner: TComponent); begin inherited; end; destructor TfConfiguracion.Destroy; begin inherited; end; procedure TfConfiguracion.FormCreate(Sender: TObject); var AItem : TListItem; begin with ListView1.Items do begin AItem := Add; AItem.Caption := 'General'; AItem.ImageIndex := AItem.Index; AItem := Add; AItem.Caption := 'Servidor de BD'; AItem.ImageIndex := AItem.Index; end; ListView1.ItemIndex := 0; end; procedure TfConfiguracion.tvArbolChange(Sender: TObject; Node: TTreeNode); begin if Assigned(FPaginaActual) then FPaginaActual.Finalize; case Node.Index of 0 : FPaginaActual := CreateFrame(pnlPagina, TfrConfGeneral); 1 : FPaginaActual := CreateFrame(pnlPagina, TfrConexionBD); end; Self.Update; pnlHeader.LabelCaption := Node.Text; end; procedure TfConfiguracion.actAceptarExecute(Sender: TObject); begin if Assigned(FPaginaActual) then FPaginaActual.Finalize; dmServer.SalvarConfiguracion; Close; end; procedure TfConfiguracion.actCancelarExecute(Sender: TObject); begin Close; end; procedure TfConfiguracion.ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); begin if Selected then begin if Assigned(FPaginaActual) then FPaginaActual.Finalize; case Item.Index of 0 : FPaginaActual := CreateFrame(pnlPagina, TfrConfGeneral); 1 : FPaginaActual := CreateFrame(pnlPagina, TfrConexionBD); end; Self.Update; pnlHeader.LabelCaption := Item.Caption; end; end; end.