THtmlViewer, TFrameViewer, and TFrameBrowser components
property OnImageRequest: TGetImageEvent;
The OnImageRequest event occurs when one or the HTML components encounters an image request and the ViewImages property is set. You can use the OnImageRequest event to supply an image stored in stream form. The stream may contain a Bitmap, GIF (including animated), JPEG, or PNG image.
The image may also be supplied at a later time if it is necessary to download it. To indicate the image will be supplied later, return the special TMemoryStream value, WaitStream, rather that an actual stream. The InsertImage method may be used when the image is available.
Usage Note
The TMemoryStream returned is not freed by the caller. The User must free this later.
This event handler converts an image file to a TMemoryStream object for test purposes.
var
MStream: TMemoryStream;
......
procedure TForm1.ImageRequest(Sender: TObject; const SRC: string;
var Stream: TMemoryStream);
var
Filename: string[80];
begin
Stream := Nil; {in case of error}
Filename := FrameViewer.HTMLExpandFilename(SRC);
if FileExists(Filename) then
try
if not Assigned(MStream) then
MStream := TMemoryStream.Create;
MStream.LoadFromFile(FileName);
Stream := MStream;
except
end;
end;
See Also