git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.DevExpressVCL@29 05c56307-c608-d34a-929d-697000501d7a
263 lines
7.5 KiB
ObjectPascal
263 lines
7.5 KiB
ObjectPascal
{*******************************************************************}
|
|
{ }
|
|
{ Developer Express Visual Component Library }
|
|
{ ExpressMemData - CLX/VCL Edition }
|
|
{ }
|
|
{ Copyright (c) 1998-2008 Developer Express Inc. }
|
|
{ ALL RIGHTS RESERVED }
|
|
{ }
|
|
{ The entire contents of this file is protected by U.S. and }
|
|
{ International Copyright Laws. Unauthorized reproduction, }
|
|
{ reverse-engineering, and distribution of all or any portion of }
|
|
{ the code contained in this file is strictly prohibited and may }
|
|
{ result in severe civil and criminal penalties and will be }
|
|
{ prosecuted to the maximum extent possible under the law. }
|
|
{ }
|
|
{ RESTRICTIONS }
|
|
{ }
|
|
{ THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES }
|
|
{ (DCU, OBJ, DLL, DPU, SO, ETC.) ARE CONFIDENTIAL AND PROPRIETARY }
|
|
{ TRADE SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER}
|
|
{ IS LICENSED TO DISTRIBUTE THE EXPRESSMEMDATA }
|
|
{ AS PART OF AN EXECUTABLE PROGRAM ONLY. }
|
|
{ }
|
|
{ THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED }
|
|
{ FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE }
|
|
{ COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE }
|
|
{ AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT }
|
|
{ AND PERMISSION FROM DEVELOPER EXPRESS INC. }
|
|
{ }
|
|
{ CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON }
|
|
{ ADDITIONAL RESTRICTIONS. }
|
|
{ }
|
|
{*******************************************************************}
|
|
|
|
unit dxmdatps;
|
|
|
|
interface
|
|
|
|
{$I cxVer.inc}
|
|
|
|
uses
|
|
{$IFDEF DELPHI6}
|
|
DesignIntf,
|
|
{$ELSE}
|
|
DsgnIntf,
|
|
{$ENDIF}
|
|
Windows, Classes, Controls, Forms, StdCtrls, dxmdaset, ExtCtrls, Dialogs,
|
|
Menus, Graphics, DB, DBGrids;
|
|
|
|
type
|
|
TfrmdxMemDataPersistent = class(TForm)
|
|
private
|
|
pnlBottom: TPanel;
|
|
pnlBottomRight: TPanel;
|
|
btnClear: TButton;
|
|
btnLoad: TButton;
|
|
btnSave: TButton;
|
|
btnOK: TButton;
|
|
btnCancel: TButton;
|
|
OpenDialog: TOpenDialog;
|
|
SaveDialog: TSaveDialog;
|
|
procedure btnClearClick(Sender: TObject);
|
|
procedure btnLoadClick(Sender: TObject);
|
|
procedure btnSaveClick(Sender: TObject);
|
|
private
|
|
FMemData: TdxCustomMemData;
|
|
FDataSource: TDataSource;
|
|
FDBGrid: TDBGrid;
|
|
|
|
procedure CreateControls;
|
|
procedure CreateDataAndGrid;
|
|
public
|
|
procedure SetMemData(AMemData: TdxCustomMemData);
|
|
end;
|
|
|
|
procedure ShowMemDataPersistentDesigner(AMemData: TdxCustomMemData; ADesigner: IDesigner);
|
|
|
|
implementation
|
|
|
|
procedure ShowMemDataPersistentDesigner(AMemData: TdxCustomMemData; ADesigner: IDesigner);
|
|
|
|
procedure SetDesignerModified;
|
|
begin
|
|
if ADesigner <> nil then
|
|
ADesigner.Modified;
|
|
end;
|
|
|
|
var
|
|
AForm: TfrmdxMemDataPersistent;
|
|
begin
|
|
AForm := TfrmdxMemDataPersistent.CreateNew(nil {$IFDEF DELPHI4}, 0 {$ENDIF});
|
|
try
|
|
AForm.CreateControls;
|
|
AForm.CreateDataAndGrid;
|
|
AForm.SetMemData(AMemData);
|
|
if AForm.ShowModal = mrOK then
|
|
begin
|
|
if AForm.FMemData.State in dsEditModes then
|
|
AForm.FMemData.Post;
|
|
AForm.FMemData.Persistent.SaveData;
|
|
AMemData.Persistent.Assign(AForm.FMemData.Persistent);
|
|
SetDesignerModified;
|
|
end;
|
|
finally
|
|
AForm.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmdxMemDataPersistent.SetMemData(AMemData: TdxCustomMemData);
|
|
begin
|
|
FMemData.CreateFieldsFromDataSet(AMemData);
|
|
FMemData.Persistent.Assign(AMemData.Persistent);
|
|
FMemData.Persistent.LoadData;
|
|
if not FMemData.Active then
|
|
FMemData.Open;
|
|
end;
|
|
|
|
procedure TfrmdxMemDataPersistent.CreateDataAndGrid;
|
|
begin
|
|
FMemData := TdxMemData.Create(self);
|
|
FDataSource := TDataSource.Create(self);
|
|
FDataSource.DataSet := FMemData;
|
|
FDBGrid := TDBGrid.Create(self);
|
|
FDBGrid.Parent := self;
|
|
FDBGrid.Align := alClient;
|
|
FDBGrid.DataSource := FDataSource;
|
|
end;
|
|
|
|
procedure TfrmdxMemDataPersistent.btnClearClick(Sender: TObject);
|
|
begin
|
|
FMemData.Close;
|
|
FMemData.Open;
|
|
end;
|
|
|
|
procedure TfrmdxMemDataPersistent.btnLoadClick(Sender: TObject);
|
|
begin
|
|
if OpenDialog.Execute then
|
|
try
|
|
FMemData.LoadFromBinaryFile(OpenDialog.FileName);
|
|
except
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmdxMemDataPersistent.btnSaveClick(Sender: TObject);
|
|
begin
|
|
if SaveDialog.Execute then
|
|
try
|
|
FMemData.SaveToBinaryFile(SaveDialog.FileName);
|
|
except
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmdxMemDataPersistent.CreateControls;
|
|
begin
|
|
Width := 473;
|
|
Height := 376;
|
|
BorderIcons := [biMaximize];
|
|
Caption := 'ExpressMemData Persistent Editor...';
|
|
Color := clBtnFace;
|
|
Position := poScreenCenter;
|
|
|
|
pnlBottom := TPanel.Create(self);
|
|
with pnlBottom do
|
|
begin
|
|
Parent := self;
|
|
Height := 42;
|
|
Align := alBottom;
|
|
BevelOuter := bvNone;
|
|
TabOrder := 0;
|
|
end;
|
|
|
|
pnlBottomRight := TPanel.Create(self);
|
|
with pnlBottomRight do
|
|
begin
|
|
Parent := pnlBottom;
|
|
Align := alRight;
|
|
BevelOuter := bvNone;
|
|
Height := 34;
|
|
end;
|
|
|
|
btnClear := TButton.Create(self);
|
|
with btnClear do
|
|
begin
|
|
Parent := pnlBottomRight;
|
|
Left := 1;
|
|
Top := 5;
|
|
Width := 82;
|
|
Height := 24;
|
|
Caption := '&Clear';
|
|
OnClick := btnClearClick;
|
|
end;
|
|
|
|
btnLoad := TButton.Create(self);
|
|
with btnLoad do
|
|
begin
|
|
Parent := pnlBottomRight;
|
|
Left := btnClear.Left + btnClear.Width + 5;
|
|
Top := btnClear.Top;
|
|
Width := btnClear.Width;
|
|
Height := btnClear.Height;
|
|
Caption := '&Load...';
|
|
OnClick := btnLoadClick;
|
|
end;
|
|
|
|
btnSave := TButton.Create(self);
|
|
with btnSave do
|
|
begin
|
|
Parent := pnlBottomRight;
|
|
Left := btnLoad.Left + btnClear.Width + 5;;
|
|
Top := btnClear.Top;
|
|
Width := btnClear.Width;
|
|
Height := btnClear.Height;
|
|
Caption := '&Save...';
|
|
OnClick := btnSaveClick
|
|
end;
|
|
|
|
btnOK := TButton.Create(self);
|
|
with btnOK do
|
|
begin
|
|
Parent := pnlBottomRight;
|
|
Left := btnSave.Left + btnClear.Width + 5;
|
|
Top := btnClear.Top;
|
|
Width := btnClear.Width;
|
|
Height := btnClear.Height;
|
|
Caption := '&OK';
|
|
Default := True;
|
|
ModalResult := 1;
|
|
end;
|
|
|
|
btnCancel := TButton.Create(self);
|
|
with btnCancel do
|
|
begin
|
|
Parent := pnlBottomRight;
|
|
Left := btnOK.Left + btnClear.Width + 5;
|
|
Top := btnClear.Top;
|
|
Width := btnClear.Width;
|
|
Height := btnClear.Height;
|
|
Cancel := True;
|
|
Caption := '&Cancel';
|
|
ModalResult := 2;
|
|
end;
|
|
|
|
pnlBottomRight.Width := btnCancel.Left + btnClear.Width + 5;
|
|
|
|
Opendialog := TOpendialog.Create(self);
|
|
with Opendialog do
|
|
begin
|
|
DefaultExt := '*.dat';
|
|
Title := 'Open';
|
|
end;
|
|
|
|
SaveDialog := TSaveDialog.Create(self);
|
|
with SaveDialog do
|
|
begin
|
|
DefaultExt := '*.dat';
|
|
Title := 'Save As';
|
|
end;
|
|
|
|
ActiveControl := btnLoad;
|
|
end;
|
|
|
|
end.
|