blobdatafrm.pas

来自「delphi本地数据库引擎」· PAS 代码 · 共 86 行

PAS
86
字号
unit BlobDataFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, DBCtrls,
  ExtCtrls, Db, TinyDB, BaseFrm;

type
  TBlobDataFormData = record
    TinyTable: TTinyTable;
    DataSource: TDataSource;
  end;

  TBlobDataForm = class(TBaseForm)
    BlobPanel: TPanel;
    BottomPanel: TPanel;
    CloseButton: TButton;
    procedure BottomPanelResize(Sender: TObject);
  private
    { Private declarations }
    FData: TBlobDataFormData;
  public
    { Public declarations }
    procedure SetData(Value: TBlobDataFormData);
    procedure SetCurFieldIdx(Value: Integer);
  end;

var
  BlobDataForm: TBlobDataForm;

implementation

uses LangMgr;

{$R *.DFM}

procedure TBlobDataForm.SetData(Value: TBlobDataFormData);
var
  I: Integer;
begin
  FData := Value;
  for I := 0 to Value.TinyTable.Fields.Count - 1 do
  begin
    if Value.TinyTable.Fields[I].IsBlob then
    begin
      case Value.TinyTable.Fields[I].DataType of
        ftGraphic:
          with TDBImage.Create(Self) do
          begin
            Parent := BlobPanel;
            Align := alClient;
            DataSource := Value.DataSource;
            DataField := Value.TinyTable.Fields[I].FieldName;
            Name := 'Blob' + IntToStr(I);
          end;
        else
          with TDBMemo.Create(Self) do
          begin
            Parent := BlobPanel;
            Align := alClient;
            Name := 'Blob' + IntToStr(I);
            Lines.Clear;
            DataSource := Value.DataSource;
            DataField := Value.TinyTable.Fields[I].FieldName;
            ScrollBars := ssVertical;
          end;
      end;
    end;
  end;
end;

procedure TBlobDataForm.SetCurFieldIdx(Value: Integer);
begin
  (FindComponent('Blob' + IntToStr(Value)) as TControl).BringToFront;
  Caption := FData.TinyTable.Fields[Value].FieldName;
end;

procedure TBlobDataForm.BottomPanelResize(Sender: TObject);
begin
  CloseButton.Left := BottomPanel.ClientWidth - CloseButton.Width - 6;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?