home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 October / PCWorld_2000-10_cd2.bin / Borland / interbase / IBConsole_src.ZIP / ibconsole / frmuDisplayBlob.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-07-24  |  2.1 KB  |  83 lines

  1. {
  2.  * The contents of this file are subject to the InterBase Public License
  3.  * Version 1.0 (the "License"); you may not use this file except in
  4.  * compliance with the License.
  5.  * 
  6.  * You may obtain a copy of the License at http://www.Inprise.com/IPL.html.
  7.  * 
  8.  * Software distributed under the License is distributed on an "AS IS"
  9.  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  10.  * the License for the specific language governing rights and limitations
  11.  * under the License.  The Original Code was created by Inprise
  12.  * Corporation and its predecessors.
  13.  * 
  14.  * Portions created by Inprise Corporation are Copyright (C) Inprise
  15.  * Corporation. All Rights Reserved.
  16.  * 
  17.  * Contributor(s): ______________________________________.
  18. }
  19.  
  20. unit frmuDisplayBlob;
  21.  
  22. interface
  23.  
  24. uses
  25.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  26.   ExtCtrls, dbTables, IBCustomDataset, DB, frmuDlgClass;
  27.  
  28. type
  29.   TfrmDisplayBlob = class(TDialog)
  30.     Bevel1: TBevel;
  31.     Image: TImage;
  32.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  33.   private
  34.     { Private declarations }
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39.   procedure DisplayBlob (const Owner: TComponent; const Field: TField; const DataSet: TIBDataSet);
  40.  
  41.  implementation
  42.  
  43. {$R *.DFM}
  44.  
  45. uses
  46.   frmuMessage, jpeg;
  47.  
  48. var
  49.   frmDispBlob: TFrmDisplayBlob;
  50.  
  51. procedure DisplayBlob (const Owner: TComponent; const Field: TField; const DataSet: TIBDataSet);
  52.  
  53. var
  54.   jpg: TBitmap;
  55.   BlobStr: TStream;
  56.  
  57. begin
  58.   if not Assigned (frmDispBlob) then
  59.     frmDispBlob := TfrmDisplayBlob.Create(Owner);
  60.  
  61.   BlobStr := DataSet.CreateBlobStream (Field, bmRead);
  62.   with frmDispBlob do begin
  63.     Caption := Field.DisplayName;
  64.     try
  65.       jpg := TBitmap.Create;
  66.       jpg.LoadFromStream (BlobStr);
  67.       Image.Picture.Assign (jpg);
  68.       Show;
  69.     except on E: Exception do
  70.       DisplayMsg ( ERR_BAD_FORMAT, E.Message);
  71.     end;
  72.   end;
  73. end;
  74.  
  75. procedure TfrmDisplayBlob.FormClose(Sender: TObject;
  76.   var Action: TCloseAction);
  77. begin
  78.   frmDispBlob.Free;
  79.   frmDispBlob := nil;
  80. end;
  81.  
  82. end.
  83.