Delphi - Streams

Streams are not very well documented. All streams are based on TStream which defines a number of virtual methods. 16 classes support the LoadFromStream and 15 support the SaveToStream methods, the one I use the most is TStrings.

Delphi uses Streams to read your components' default parameters from the *.dfm files (which are actually stored as a resource in the *.exe files).

Stream Classes | Streaming Utilities | TMemoryStream | XP RichEdit Design Problem

Stream Classes

It is fairly difficult to determine what stream classes are available - I have never found a list of them. (A partial list is available on the TStream help page.) The following hierarchy is based on searching the source files for class(TStream).

Streaming Utilities

There are numerous utilities that use streams. These are only a few.


Using this is slightly confusing - it works on a buffer ... but buffer is never defined or explained. The following is based on trial and error.

XP RichEdit Design Problem

I use rich edit controls to display text and to render *.rtf files. (*.rtf files are rendered only when they are read via a stream - my Help Generator application depends on this working.) Imagine my surprise when a working Windows 98 application crashed on Windows XP.

Using text files greater than 160 K, the following code works fine in Windows 98 but fails with a resource problem in Windows XP.

The following code works in both 98 and XP. This also works in both. This change also improved the program speed - from 12 seconds (string assignment) to 1 second (LoadFromStream) to copy the data.

Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / Languages / Delphi / Streams.html