2021年11月21日 星期日

Streaming restoring components DFM panel stream savetofile delphi

https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TReader

InsertComponent RegisterClasses ObjectTextToBinary 

ReadComponent WriteComponent 

VclRtl

ReadComponentRes  
WriteComponentRes  

    TFileStream  – 處理文件。
    TStringStream - 內存中的字符串操作。
    TMemoryStream - 使用內存緩衝區。
    TWinSocketStream - 通過套接字連接讀取和寫入。
    TOleStream - 使用 COM 接口進行讀寫。
TBufferedFileStream
TMemoryStream 是一種在動態內存中存儲數據的流。
TWinSocketStream 是一個流,它為應用程序提供讀寫套接字連接的服務。
TOleStream 通過 OLE 對象提供的流接口來讀寫信息。TActiveXControl


System.BlockWrite - RAD Studio API Documentation
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Structured_Types_(Delphi)
Standard Routines and Input-Output
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Standard_Routines_and_Input-Output

System.TTextRec
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.TTextRec

System.SysUtils.TSearchRec
Using the Eof and Bof Properties
System.TFileRec - RAD Studio API Documentation

System.Net.Mime.TMultipartFormData Form data encoded as a MIME multipart message following the HTML 4 standard.
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_an_HTTP_Client
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Net.Mime.TMultipartFormData

delphi ObjectTextToBinary ComponentToString
ObjectBinaryToText ObjectTextToBinary ObjectResourceToText ObjectTextToResource ReadResHeader
ComponentToString (Delphi) - RAD Studio Code Examples
System.Classes.ObjectTextToBinary - Embarcadero DocWiki
TObjectTextEncoding


var  
  m : TMemoryStream;  
  f : TFileStream;  
  begin  
  f := TFileStream.Create('c:\testdfm.abnt',fmOpenRead);  
  m := TMemoryStream.Create;  
  try  
    ObjectTextToBinary(f,m);  
    m.Position := 0;  
    dxRibbon1.Free;  
    form2.DestroyComponents;  
    m.ReadComponent(self);  
    dxRecalculateNonClientPart(Handle);  
  finally  
    m.Free;  
    f.Free;  
  end;  
end; 
    BinStream:TMemoryStream;

    StrStream: TStringStream;
 
    BinStream := TMemoryStream.Create;

      StrStream := TStringStream.Create(s);
        BinStream.WriteComponent(組件);

        BinStream.Seek(0, soFromBeginning);

        ObjectBinaryToText(BinStream, StrStream);

        StrStream.Seek(0, soFromBeginning);

        結果:= StrStream.DataString;

        StrStream.Free;
      BinStream.Free

  function StringToComponentProc(Value: string): TComponent;

    StrStream: TStringStream;

    BinStream:TMemoryStream;

    StrStream := TStringStream.Create(Value);

      BinStream := TMemoryStream.Create;

        ObjectTextToBinary(StrStream, BinStream);

        BinStream.Seek(0, soFromBeginning);

        結果:= BinStream.ReadComponent(nil);

    Memo1.Text:= ComponentToStringProc(ScrollBar1);

    ScrollBar1.Free;

    ScrollBar1:= (StringToComponentProc(Memo1.Text) as TMyScrollBar);

    ScrollBar1.Parent:= Form1;

    ScrollBar1.Visible:= TRUE;
 
  程序 TForm1.FormCreate(Sender: TObject);

    ScrollBar1:= TMyScrollBar.Create(Form1);

    ScrollBar1.Parent:= Form1;

    ScrollBar1.Visible:= TRUE;

    ScrollBar1.Top:= 48;

    ScrollBar1.Left:= 250;

    ScrollBar1.Name:= 'Ricksbar';
 

  https://flylib.com/books/en/2.37.1/core_library_classes.html

ClientDataSet BLOB Binary Large Object TBlobField

 ClientDataSet  BLOB Binary Large Object   TBlobField

uses IOUtils, MMSystem;

  MediaPath, Path: string;

  with ClientDataSet1 do begin

    FieldDefs.Add('WavFileName', ftString, 32);

    FieldDefs.Add('WAV', ftBlob);

    CreateDataSet;
 
  MediaPath := GetEnvironmentVariable('SystemRoot') + '\Media\';

  for Path in TDirectory.GetFiles(MediaPath, '*.wav') do

    ClientDataSet1.Append;

    ClientDataSet1['WavFileName'] := ExtractFileName(Path);

    TBlobField(ClientDataSet1.FieldByName('WAV')).LoadFromFile(Path);

  ClientDataSet1.MergeChangeLog;
 
  BlobStream: TClientBlobStream;

  BlobField: TBlobField;

  BlobField := ClientDataSet1.FieldByName('WAV') as TBlobField;

  BlobStream := TClientBlobStream.Create(BlobField, bmRead);

  Win32Check(PlaySound(BlobStream.Memory, 0, SND_SYNC or SND_MEMORY));

  BlobStream.Free;

 

    01.DataSetProvider.Options.poPropogateChanges:=True;  
    02.procedure TForm1.DataSetProvider1AfterUpdateRecord(Sender: TObject;  
    03.SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;  
    04.UpdateKind: TUpdateKind);  
    05.begin  
    06.//DstId TADODataset  
     07.//FId self-growth fields  
    08.if   UpdateKind=ukInsert then  
    09.    begin  
    10.       DstId.CommandText:='select @@Identity as FId ';  
    11.       DstId.Open;  
    12.       DeltaDS.FieldByName('FId').ReadOnly:=False;  
    13.       DeltaDS.FieldByName('FId').NewValue:=DstId.FieldByName('FId').AsInteger ;  
    14.       DstId.Close;  
    15.   end;  
    16.end;  
01.procedure TProducts.DataSetProvider1BeforeUpdateRecord(Sender: TObject;  
02.SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;  
03.UpdateKind: TUpdateKind; var Applied: Boolean);  
04.begin  
05.//DstProduct from the table Name  
 06.//CategoryID from the associated field of the table for the word from the segment by a primary table  
 07.// qryIdentity is TADOQuery qryIdentity.SQL: = 'select @@ identity'  
08.if (UpdateKind = ukInsert) and  
09.(SourceDS = DstProduct) and  
10.(DeltaDS.FieldByName('CategoryID').Value = Unassigned)   ) then  
11.begin  
12.    if DeltaDS.BOF then  
13.    begin  
14.      qryIdentity.Close;  
15.      qryIdentity.Open;  
16.    end;  
17.    DeltaDS.FieldByName('CategoryID').NewValue := qryIdentity.Fields[0].Value;  
18.end;  
19.end;