Programalama > DELPHI

Etiketler: open, source, ahmtdbmemoview

Ort. 0
Puan ver:
unit AHMTDBMemoView;
interface
{$I AHM.INC}
uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, DBCtrls, ExtCtrls, Buttons,AHMDialogs,DB
  {$IFNDEF AHMINPRISE3},DBTables{$ENDIF};

type
  TAHMMemoViewForm = class(TForm)
    Panel1: TPanel;
    DBMemo1: TDBMemo;
    Panel2: TPanel;
    SpeedButton1: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
  private
  public
  end;
  TAHMDBMemoView = class(TAHMAdvDialogComponent)
  private
    freadonly : Boolean;
    FFieldDataLink: TFieldDataLink;
    function GetDataField : String;
    procedure SetDataField(Value: String );
    function GetDataSource : TDataSource;
    procedure SetDataSource( Value : TDataSource );
  protected
    procedure Notification(AComponent: TComponent;Operation: TOperation); override;
  public
    constructor Create( AOwner: TComponent ); override;
    destructor Destroy; override;
    function Execute: Boolean; override;
  published
    property Readonly : Boolean read freadonly write freadonly default false;
    property DataField: String read GetDataField write SetDataField;
    property DataSource: TDataSource read GetDataSource write SetDataSource;
  end;


implementation
{$IFDEF AHMCOMPILE}{$R *.DSF}
{$ELSE} {$R *.DFM} {$ENDIF}


function TAHMDBMemoView.Execute: Boolean;
var MemoViewForm: TAHMMemoViewForm;
begin
  if (ffielddatalink<>nil) and (Datasource<>nil) then
  begin
    MemoViewForm:= TAHMMemoViewForm.Create(Application);
    with MemoViewForm do
    try
      SetFormProperties(MemoViewForm);
      DBMemo1.Readonly:=freadonly;
      DBMemo1.DataSource := DataSource;
      DBMemo1.DataField := DataField;
      ShowModal;
      if FFieldDataLink.Edit then DataSource.DataSet.Post
                             else DataSource.DataSet.Cancel;
    finally
      Free;
    end;
    result := true;
  end else result:=false;
end;

procedure TAHMDBMemoView.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (FFieldDataLink <> nil) and (AComponent = DataSource) then SetDataSource(nil);
end;

function TAHMDBMemoView.GetDataField: String;
begin
  Result := FFieldDataLink.FieldName;
end;

procedure TAHMDBMemoView.SetDataField(Value : String);
begin
  FFieldDataLink.FieldName := Value;
end;

function TAHMDBMemoView.GetDataSource: TDataSource;
begin
  GetDataSource := FFieldDataLink.DataSource;
end;

procedure TAHMDBMemoView.SetDataSource(Value : TDataSource);
begin
  FFieldDataLink.DataSource := Value;
  if Value <> nil then Value.FreeNotification(Self);
end;

destructor TAHMDBMemoView.Destroy;
begin
  FFieldDataLink.Free;
  inherited Destroy;
end;

constructor TAHMDBMemoView.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FReadonly := false;
  FFieldDataLink := TFieldDataLink.Create;
end;

procedure TAHMMemoViewForm.SpeedButton1Click(Sender: TObject);
begin
  close;
end;

end.


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.