Board index » delphi » TmemoryStream

TmemoryStream

hi, can anybody post a little example for writing and loading with
Tmemorystream ?

thanks,

Alex

 

Re:TmemoryStream


Quote
"Alex" <Darkside_of_the_M...@msn.com> wrote:
>hi, can anybody post a little example for writing and loading with
>Tmemorystream ?

>thanks,

>Alex

Here is an example.  This example loads strings from a blob into
several combo boxes based on information entered into the system.
The TMemoryStream usage is in the nested procedure LoadData, which
receives a reference to the Memo Field and DBComboBox.

procedure TfrmLineItems.LoadItemsFromStream;
var Memory: TMemoryStream;

  procedure LoadData(fld: TMemoField; cbo: TDBComboBox);
  begin
    fld.SaveToStream(Memory);
    Memory.Position := 0;
    cbo.Items.LoadFromStream(Memory);
    Memory.Clear;
  end;

begin
  try
    Memory := TMemoryStream.Create;
    LoadData(dmDGP.tblDGPDGPGlassType, cboGlassType);
    LoadData(dmDGP.tblDGPDGPGlassTint, cboDGPTint);
    LoadData(dmDGP.tblDGPDGPGlassThickness, cboDGPGlassThickness);
    LoadData(dmDGP.tblDGPDGPChannelColor, cboDGPChannelColor);
    LoadData(dmHardware.tblHardwareOperator, cboHardwareOperator);
    LoadData(dmHardware.tblHardwareHinges, cboHardwareHinges);
    LoadData(dmHardware.tblHardwareInteriorColor,
cboHardwareInteriorColor);
    LoadData(dmHardware.tblHardwareExteriorColor, cboHardwareColor);
    LoadData(dmHardware.tblHardwareLock, cboHardwareLock);
    LoadData(dmHardware.tblHardwareJambLiner, cboHardwareJambLiner);
    LoadData(dmHardware.tblHardwareRestricted, cboRestricted);
    LoadData(dmHardware.tblHardwareSill, cboHardwareSill);
    LoadData(dmHardware.tblHardwareHingeType, cboHingeType);
    LoadData(dmHardware.tblHardwareHingeFinish, cboHingeFinish);
  finally
    Memory.Free;
  end;
end;

Hope this helps.

--
Mike Sherrane                                      blue mountain software
Senior Software Engineer

         Hired Guns -- The Best in the Business since 1986
                   Delphi, C++, Progress,  Visual BASIC

http://bluemtn.com/                            770-857-TECH, Atlanta

Other Threads