home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / nastroje / d3456 / KBMWABD.ZIP / WABD_EditTable.pas < prev    next >
Pascal/Delphi Source File  |  2001-07-15  |  22KB  |  710 lines

  1. unit WABD_EditTable;
  2.  
  3. {$I kbmWABD.inc}
  4.  
  5. interface
  6.  
  7. uses SysUtils, Classes, WABD_Objects,Dialogs,DB,Graphics;
  8.  
  9. type
  10.    TWABD_EditTable = class;
  11.    TWABD_DBEditTable = class;
  12.  
  13.    // Derive from TWABD_FormSection_Base insead of just TWABD_FormSection
  14.    // so that the user can NOT edit the child controls in the WABD Form
  15.    // designer
  16.    TWABD_OnResizeTable = procedure(Sender:TObject) of object;
  17.    TWABD_OnRenderTable = procedure(Sender:TObject) of object;
  18.    TWABD_OnRenderTableCell = procedure(Sender:TObject; Cell:TWABD_SectionObject; Col,Row:integer) of object;
  19.    TWABD_OnRenderTableHeaderCell = procedure(Sender:TObject; HeaderCell:TWABD_Label; Col:integer) of object;
  20.    TWABD_InternalTable = class(TWABD_FormSection_Grid)
  21.    protected
  22.       FCols       : integer;
  23.       FRows       : integer;
  24.       FHeaders    : TList;
  25.       FCells      : TList;
  26.       FHeader     : boolean;
  27.       FColWidths  : array [0..254] of integer;
  28.       FColOfs     : array [0..254] of integer;
  29.       FOnResize   :TWABD_OnResizeTable;
  30.       FOnRender   :TWABD_OnRenderTable;
  31.       FOnRenderCell:TWABD_OnRenderTableCell;
  32.       FOnRenderHeaderCell:TWABD_OnRenderTableHeaderCell;
  33.  
  34.       function    GetCellObject(Col, Row: integer): TWABD_SectionObject;
  35.       function    GetHeader(Col: integer): string;
  36.       procedure   SetHeader(Col: integer; const Value: string);
  37.       function    GetColWidth(Col:integer):integer;
  38.       procedure   SetColWidth(Col:integer; AWidth:integer);
  39.  
  40.       procedure   SetHeaderShown(Shown:boolean);
  41.       function    GetHeaderObject(Col:integer): TWABD_Label;
  42.       procedure   Resize;
  43.  
  44.       function    CreateCell(Col,Row:integer):TWABD_SectionObject; virtual; abstract;
  45.    public
  46.       constructor Create(AOwner: TComponent); override;
  47.       destructor  Destroy; override;
  48.       function    Object_To_HTML:string; override;
  49.       property    Headers[Col: integer]: string read GetHeader write SetHeader;
  50.       property    HeaderObjects[Col:integer]:TWABD_Label read GetHeaderObject;
  51.       property    CellObjects[Col,Row:integer]:TWABD_SectionObject read GetCellObject;
  52.       property    ColWidth[Col:integer]:integer read GetColWidth write SetColWidth;
  53.    published
  54.       property    OnResize:TWABD_OnResizeTable read FOnResize write FOnResize;
  55.       property    OnRender:TWABD_OnRenderTable read FOnRender write FOnRender;
  56.       property    OnRenderCell:TWABD_OnRenderTableCell read FOnRenderCell write FOnRenderCell;
  57.       property    OnRenderHeaderCell:TWABD_OnRenderTableHeaderCell read FOnRenderHeaderCell write FOnRenderHeaderCell;
  58.       property    Header:boolean read FHeader write SetHeaderShown;
  59.    end;
  60.  
  61.    TWABD_EditTable = class(TWABD_InternalTable)
  62.    protected
  63.       FEditSize   : integer;
  64.  
  65.       function    GetCols:integer;
  66.       function    GetRows:integer;
  67.       procedure   SetCols(NewCols: integer);
  68.       procedure   SetRows(NewRows: integer);
  69.  
  70.       function    CreateCell(Col,Row:integer):TWABD_SectionObject; override;
  71.       function    GetCell(Col, Row: integer): string;
  72.       procedure   SetCell(Col, Row: integer; const Value: string);
  73.    public
  74.       constructor Create(AOwner: TComponent); override;
  75.       destructor  Destroy; override;
  76.       property    Cells[Col,Row: integer]: string read GetCell write SetCell;
  77.    published
  78.       property    Cols: integer read GetCols write SetCols;
  79.       property    Rows: integer read GetRows write SetRows;
  80.       property    EditSize: integer read FEditSize write FEditSize;
  81.    end;
  82.  
  83.    TWABD_DBEditTable_DataLink = class(TDataLink)
  84.    private
  85.       FOnActiveChanged:TNotifyEvent;
  86.       FOnDatasetChanged:TNotifyEvent;
  87.       FOnLayoutChanged:TNotifyEvent;
  88.       FEditTable:TWABD_DBEditTable;
  89.    protected
  90.       procedure DatasetChanged; override;
  91.       procedure ActiveChanged; override;
  92.       procedure LayoutChanged; override;
  93.    published
  94.       property OnActiveChanged:TNotifyEvent read FOnActiveChanged write FOnActiveChanged;
  95.       property OnDatasetChanged:TNotifyEvent read FOnDatasetChanged write FOnDatasetChanged;
  96.       property OnLayoutChanged:TNotifyEvent read FOnLayoutChanged write FOnLayoutChanged;
  97.    end;
  98.  
  99.    TWABD_DBEditTable = class(TWABD_EditTable)
  100.    protected
  101.       FDataLink   : TWABD_DBEditTable_DataLink;
  102.       FActiveRec  : integer;
  103.       FRecordCount: integer;
  104.       FCalcPages  : boolean;
  105.       FRowIDs     : TList;
  106.       FShowNavigator:boolean;
  107.       procedure   RecountRecords(Sender:TObject);
  108.       function    GetDataSource: TDataSource;
  109.       procedure   SetDataSource(NewDataSource: TDataSource);
  110.       procedure   SetShowNavigator(Shown:boolean);
  111.       procedure   Notification(AComponent: TComponent; Operation: TOperation); override;
  112.       function    IsLinked:boolean;
  113.       procedure   Populate(FromRecord:integer);
  114.       function    CreateCell(Col,Row:integer):TWABD_SectionObject; override;
  115.    public
  116.       constructor Create(AOwner: TComponent); override;
  117.       destructor  Destroy; override;
  118.       function    Object_To_HTML:string; override;
  119.    published
  120.       property    DataSource: TDataSource read GetDataSource write SetDataSource;
  121.       property    ShowNavigator:boolean read FShowNavigator write SetShowNavigator;
  122.    end;
  123.  
  124. implementation
  125.  
  126. // TWABD_InternalTable.
  127. constructor TWABD_InternalTable.Create(AOwner: TComponent);
  128. begin
  129.      inherited;
  130.      FCells     := TList.Create;
  131.      FHeaders   := TList.Create;
  132.      GridX      := 70;
  133.      GridY      := 25;
  134.      CellBorder := 0;
  135. end;
  136.  
  137. destructor TWABD_InternalTable.Destroy;
  138. var
  139.    i:integer;
  140. begin
  141.      for i:=0 to FCells.count-1 do
  142.          TWABD_SectionObject(FCells.Items[i]).free;
  143.      for i:=0 to FHeaders.count-1 do
  144.          TWABD_SectionObject(FHeaders.Items[i]).free;
  145.      FCells.Free;
  146.      FHeaders.Free;
  147.      inherited;
  148. end;
  149.  
  150. procedure TWABD_InternalTable.SetHeaderShown(Shown:boolean);
  151. begin
  152.      FHeader:=Shown;
  153.      Resize;
  154. end;
  155.  
  156. function TWABD_InternalTable.Object_To_HTML:string;
  157. var
  158.    x,y,n,h:integer;
  159. begin
  160.      // Determine columns widths.
  161.      for x:=0 to FCols-1 do
  162.      begin
  163.           n:=0;
  164.  
  165.           // Check if header width bigger than predetermined.
  166.           if (FHeader) then
  167.              with TWABD_SectionObject(FHeaders[x]) do
  168.                   if Width>n then n:=Width;
  169.  
  170.           // Check if cell widths bigger than predetermined.
  171.           for y:=0 to FRows-1 do
  172.               with TWABD_SectionObject(FCells[x*FRows+y]) do
  173.                    if Width>n then n:=Width;
  174.  
  175.           FColWidths[x]:=n;
  176.      end;
  177.  
  178.      // Let appl. programmer change defaults.
  179.      if assigned(FOnRenderHeaderCell) then
  180.         for x:=0 to FCols-1 do
  181.             FOnRenderHeaderCell(self,FHeaders.Items[x],x);
  182.  
  183.      if assigned(FOnRenderCell) then
  184.         for x:=0 to FCols-1 do
  185.             for y:=0 to FRows-1 do
  186.                 FOnRenderCell(self,FCells.Items[x*FRows + y],x,y);
  187.  
  188.      if assigned(FOnRender) then FOnRender(self);
  189.  
  190.      // Recalculate col offsets.
  191.      n:=0;
  192.      for x:=0 to FCols-1 do
  193.      begin
  194.           FColOfs[x]:=n;
  195.           h:=0;
  196.  
  197.           // Set header ofs if any header.
  198.           if (FHeader) then
  199.              with TWABD_SectionObject(FHeaders[x]) do
  200.              begin
  201.                   LeftPos:=n;
  202.                   TopPos:=h;
  203.                   Width:=FColWidths[x];
  204.                   inc(h,GridY);
  205.              end;
  206.  
  207.           // Update cell positions.
  208.           for y:=0 to FRows-1 do
  209.               with TWABD_SectionObject(FCells[x*FRows+y]) do
  210.               begin
  211.                    LeftPos:=n;
  212.                    TopPos:=h;
  213.                    inc(h,GridY);
  214.               end;
  215.  
  216.           n:=n+FColWidths[x];
  217.      end;
  218.  
  219.      Result:=inherited Object_To_HTML;
  220. end;
  221.  
  222. function TWABD_InternalTable.GetCellObject(Col, Row: integer): TWABD_SectionObject;
  223. begin
  224.      if (Col<0) or (Col>=FCols) or (Row<0) or (Row>=FRows) then raise Exception.CreateFmt('Col or Row out of range. (Col=%d,Row=%d)',[Col,Row]);
  225.      Result := FCells.Items[Col * FRows + Row];
  226. end;
  227.  
  228. function TWABD_InternalTable.GetHeader(Col:integer):string;
  229. var
  230.    nl:TWABD_Label;
  231. begin
  232.      nl:=FHeaders.Items[Col];
  233.      Result:=nl.Caption;
  234. end;
  235.  
  236. procedure TWABD_InternalTable.SetHeader(Col:integer; const Value:string);
  237. var
  238.    nl:TWABD_Label;
  239. begin
  240.      nl:=FHeaders.Items[Col];
  241.      nl.Caption:=Value;
  242. end;
  243.  
  244. function TWABD_InternalTable.GetColWidth(Col:integer):integer;
  245. begin
  246.      if (Col<0) or (Col>254) then raise Exception.CreateFmt('Column number out of range. Col=%d',[Col]);
  247.      Result:=FColWidths[Col];
  248. end;
  249.  
  250. procedure TWABD_InternalTable.SetColWidth(Col:integer; AWidth:integer);
  251. begin
  252.      if (Col<0) or (Col>254) then raise Exception.CreateFmt('Column number out of range. Col=%d',[Col]);
  253.      FColWidths[Col]:=AWidth;
  254. end;
  255.  
  256. function TWABD_InternalTable.GetHeaderObject(Col:integer):TWABD_Label;
  257. begin
  258.      Result := FHeaders.Items[Col];
  259. end;
  260.  
  261. procedure TWABD_InternalTable.Resize;
  262. var
  263.    i, x, y : integer;
  264.    no      : TWABD_SectionObject;
  265.    nl      : TWABD_Label;
  266. begin
  267.      // Remove all headers.
  268.      for i := FHeaders.Count-1 downto 0 do
  269.      begin
  270.           TObject(FHeaders[i]).Free;
  271.           FHeaders.Delete(i);
  272.      end;
  273.  
  274.      // Remove all cells.
  275.      for i := FCells.Count-1 downto 0 do
  276.      begin
  277.           TObject(FCells[i]).Free;
  278.           FCells.Delete(i);
  279.      end;
  280.  
  281.      // Should a header line be generated?
  282.      if (FHeader) then
  283.      begin
  284.           for x:=0 to FCols-1 do
  285.           begin
  286.                nl:=TWABD_Label.Create(Self);
  287.                nl.Parent:=Self;
  288.                nl.Name := Format('%s_Hdr_x%d',[Name,x]);
  289.                nl.Width:=GridX-1;
  290.                nl.Height:=GridY-1;
  291.                nl.Caption:='COL '+inttostr(x);
  292.                FHeaders.Add(nl);
  293.           end;
  294.      end;
  295.  
  296.      // Generate cells.
  297.      for x := 0 to FCols-1 do begin
  298.         for y := 0 to FRows-1 do begin
  299.            no := CreateCell(x,y);
  300.            if no=nil then Raise Exception.CreateFmt('Cell x=%d,y=%d is nil.',[x,y]);
  301.            no.Parent  := Self;
  302.            no.Name    := Format('%s_x%d_y%d', [Name, x, y]);
  303.            FCells.Add(no);
  304.         end;
  305.      end;
  306.  
  307.      if assigned(FOnResize) then FOnResize(self);
  308. end;
  309.  
  310. // TWABD_EditTable
  311. constructor TWABD_EditTable.Create(AOwner: TComponent);
  312. begin
  313.      inherited;
  314.      FEditSize:=7;
  315.      FCols      := 5;
  316.      FRows      := 5;
  317.      Resize;
  318. end;
  319.  
  320. destructor TWABD_EditTable.Destroy;
  321. begin
  322.      inherited;
  323. end;
  324.  
  325. function TWABD_EditTable.GetCols:integer;
  326. begin
  327.      Result:=FCols;
  328. end;
  329.  
  330. function TWABD_EditTable.GetRows:integer;
  331. begin
  332.      Result:=FRows;
  333. end;
  334.  
  335. procedure TWABD_EditTable.SetCols(NewCols: integer);
  336. begin
  337.      FCols := NewCols;
  338.      Resize;
  339. end;
  340.  
  341. procedure TWABD_EditTable.SetRows(NewRows: integer);
  342. begin
  343.      FRows := NewRows;
  344.      Resize;
  345. end;
  346.  
  347. function TWABD_EditTable.CreateCell(Col,Row:integer):TWABD_SectionObject;
  348. var
  349.    ne:TWABD_Edit;
  350. begin
  351.      ne:=TWABD_Edit.Create(self);
  352.      if ne<>nil then
  353.      begin
  354.           ne.Size:=FEditSize;
  355.           ne.Width:=FEditSize*10;
  356.           ne.Text:='';
  357.      end;
  358.      Result:=ne;
  359. end;
  360.  
  361. function TWABD_EditTable.GetCell(Col, Row: integer): string;
  362. var
  363.    ne : TWABD_Edit;
  364. begin
  365.      ne := TWABD_Edit(GetCellObject(Col,Row));
  366.      Result := ne.Text;
  367. end;
  368.  
  369. procedure TWABD_EditTable.SetCell(Col, Row: integer; const Value: string);
  370. var
  371.    ne : TWABD_Edit;
  372. begin
  373.      ne := TWABD_Edit(GetCellObject(Col,Row));
  374.      ne.Text := Value;
  375. end;
  376.  
  377. // TWABD_DBEditTable_DataLink
  378. procedure TWABD_DBEditTable_DataLink.ActiveChanged;
  379. begin
  380.      LayoutChanged;
  381.      if assigned(FOnActiveChanged) then FOnActiveChanged(self);
  382. end;
  383.  
  384. procedure TWABD_DBEditTable_DataLink.LayoutChanged;
  385. var
  386.    i:integer;
  387. begin
  388.      with DataSource.Dataset,FEditTable do
  389.      begin
  390.           if Active then
  391.           begin
  392.                FCols:=FieldCount;
  393.                Resize;
  394.  
  395.                // Setup headerline.
  396.                if FHeader then
  397.                begin
  398.                     for i:=0 to Cols-1 do
  399.                         with TWABD_Label(FHeaders.Items[i]) do
  400.                         begin
  401.                              Caption:=Fields[i].DisplayLabel;
  402.                         end;
  403.                end;
  404.           end;
  405.      end;
  406.      if assigned(FOnLayoutChanged) then FOnLayoutChanged(self);
  407. end;
  408.  
  409. procedure TWABD_DBEditTable_DataLink.DatasetChanged;
  410. begin
  411.      if assigned(FOnDatasetChanged) then FOnDatasetChanged(self);
  412. end;
  413.  
  414. // TWABD_DBEditTable
  415. constructor TWABD_DBEditTable.Create(AOwner: TComponent);
  416. begin
  417.      inherited;
  418.      FRowIDs:=TList.Create;
  419.      FDataLink:=TWABD_DBEditTable_DataLink.Create;
  420.      FDataLink.FEditTable:=self;
  421.      FDataLink.DataSource:=nil;
  422.      FDataLink.OnActiveChanged:=RecountRecords;
  423.      FCols      := 5;
  424.      FRows      := 5;
  425.      FShowNavigator:=true;
  426.      Resize;
  427. end;
  428.  
  429. destructor TWABD_DBEditTable.Destroy;
  430. begin
  431.      FDataLink.free;
  432.      FRowIDs.free;
  433.      inherited;
  434. end;
  435.  
  436. function TWABD_DBEditTable.CreateCell(Col,Row:integer):TWABD_SectionObject;
  437. var
  438.    ft:TFieldType;
  439.    ni:TWABD_LiveImage;
  440.    ne:TWABD_Edit;
  441.    nl:TWABD_Label;
  442.    nchb:TWABD_CheckBox;
  443.    nmm:TWABD_Memo;
  444.    fld:TField;
  445. begin
  446.      // Get corresponding field.
  447.      if not IsLinked then
  448.         fld:=nil
  449.      else
  450.          fld:=DataSource.Dataset.Fields[Col];
  451.  
  452.      // Create control of correct type according to field.
  453.      if (fld=nil) or (fld.ReadOnly) then
  454.      begin
  455.           nl:=TWABD_Label.Create(self);
  456.           if (nl<>nil) and (fld=nil) then nl.Caption:='<N/A>';
  457.           Result:=nl;
  458.           exit;
  459.      end;
  460.  
  461.      // Determine field type.
  462.      ft:=fld.DataType;
  463.      if (ft=ftBlob) then
  464.         with TBlobField(fld) do
  465.         begin
  466.              if (BlobType=ftGraphic) or (BlobType=ftTypedBinary) then ft:=ftGraphic
  467.              else if (BlobType=ftMemo) or (BlobType=ftFmtMemo) then ft:=ftMemo;
  468.         end;
  469.  
  470.      case ft of
  471.           ftTypedBinary,
  472.           ftGraphic:
  473.             begin
  474.                  ni:=TWABD_LiveImage.Create(nil);
  475.                  if ni<>nil then
  476.                  begin
  477.                       ni.ImageWidth:=GridX-1;
  478.                       ni.ImageHeight:=GridY-1;
  479.                       ni.Width:=ni.ImageWidth;
  480.                       ni.Height:=ni.ImageHeight;
  481.                  end;
  482.                  Result:=ni;
  483.             end;
  484.  
  485.           ftMemo,ftFmtMemo:
  486.             begin
  487.                  nmm:=TWABD_Memo.Create(nil);
  488.                  if nmm<>nil then
  489.                  begin
  490.                       nmm.Width:=GridX-1;
  491.                       nmm.Height:=GridY-1;
  492.                  end;
  493.                  Result:=nmm;
  494.             end;
  495.  
  496. {$ifndef LEVEL3}
  497.           ftWideString,ftFixedChar,
  498. {$endif}
  499.           ftString:
  500.             begin
  501.                  ne:=TWABD_Edit.Create(nil);
  502.                  if ne<>nil then
  503.                  begin
  504.                       ne.Text:='';
  505.                       ne.Size:=fld.Size;
  506.                       ne.MaxLength:=ne.Size;
  507.                       ne.Width:=ne.Size*10;
  508.                  end;
  509.                  Result:=ne;
  510.             end;
  511.  
  512. {$ifndef LEVEL3}
  513.           ftLargeInt,
  514. {$endif}
  515.           ftSmallInt,ftInteger,ftWord:
  516.             begin
  517.                  ne:=TWABD_Edit.Create(nil);
  518.                  if ne<>nil then
  519.                  begin
  520.                       ne.Text:='';
  521.                       ne.Size:=6;
  522.                       ne.Width:=ne.Size*10;
  523.                  end;
  524.                  Result:=ne;
  525.             end;
  526.  
  527.           ftBoolean:
  528.             begin
  529.                  nchb:=TWABD_CheckBox.Create(nil);
  530.                  if nchb<>nil then
  531.                  begin
  532.                       nchb.Caption:='';
  533.                       nchb.Width:=20;
  534.                  end;
  535.                  Result:=nchb;
  536.             end;
  537.      else
  538.           begin
  539.                nl:=TWABD_Label.Create(nil);
  540.                if nl<>nil then
  541.                begin
  542.                     nl.Caption:='';
  543.                     nl.Width:=200;
  544.                end;
  545.                Result:=nl;
  546.           end;
  547.      end;
  548. end;
  549.  
  550. procedure TWABD_DBEditTable.Notification(AComponent: TComponent; Operation: TOperation);
  551. begin
  552.      inherited;
  553.      if (Operation = opRemove) and (AComponent = FDataLink.DataSource) then
  554.         FDataLink.DataSource := nil;
  555. end;
  556.  
  557. procedure TWABD_DBEditTable.SetShowNavigator(Shown:boolean);
  558. begin
  559.      FShowNavigator:=Shown;
  560.      Resize;
  561. end;
  562.  
  563. function TWABD_DBEditTable.GetDataSource: TDataSource;
  564. begin
  565.      Result := FDataLink.DataSource;
  566. end;
  567.  
  568. procedure TWABD_DBEditTable.SetDataSource(NewDataSource: TDataSource);
  569. begin
  570.      FDataLink.DataSource := NewDataSource;
  571.      if NewDataSource<>nil then NewDataSource.FreeNotification(self);
  572. end;
  573.  
  574. function TWABD_DBEditTable.IsLinked:boolean;
  575. begin
  576.      Result:=(FDataLink<>nil) and (FDataLink.DataSource<>nil) and (FDataLink.DataSource.DataSet<>nil) and
  577.          (FDataLink.DataSource.DataSet.Active);
  578. end;
  579.  
  580. procedure TWABD_DBEditTable.RecountRecords(Sender:TObject);
  581. begin
  582.      if IsLinked then
  583.         with FDataLink.DataSource.DataSet do
  584.         begin
  585.              if Active then FActiveRec:=1
  586.              else FActiveRec:=0;
  587.              if (Active) and (FCalcPages) then
  588.              begin
  589.                  Last;
  590.                  First;
  591.                  FRecordCount:=RecordCount;
  592.              end;
  593.         end;
  594. end;
  595.  
  596. function TWABD_DBEditTable.Object_To_HTML:string;
  597. begin
  598.      Populate(0);
  599.      Result:=inherited Object_To_HTML;
  600. end;
  601.  
  602. procedure TWABD_DBEditTable.Populate(FromRecord:integer);
  603. var
  604.    x,y:integer;
  605.    bm:TBookmark;
  606.    no:TWABD_SectionObject;
  607.    fld:TField;
  608.    ft:TFieldType;
  609.    bmp:TBitmap;
  610. begin
  611.      if not IsLinked then exit;
  612.  
  613.      // Setup cell info.
  614.      with DataSource.DataSet do
  615.      begin
  616.           if Active then
  617.           begin
  618.              bm:=GetBookmark;
  619.              try
  620.                 // Clear bookmarks.
  621.                 for y:=FRowIDs.count-1 downto 0 do
  622.                 begin
  623.                      FreeBookmark(TBookmark(FRowIDs.Items[y]));
  624.                      FRowIDs.Delete(y);
  625.                 end;
  626.  
  627.                 // Fill in the values.
  628.                 for y:=0 to Rows-1 do
  629.                 begin
  630.                      // Store bookmarks for easy reference to the record later on update.
  631.                      FRowIDs.Add(GetBookMark);
  632.  
  633.                      // Copy record contents to the controls.
  634.                      for x:=0 to Cols-1 do
  635.                      begin
  636.                           no:=TWABD_SectionObject(FCells.Items[x*Rows+y]);
  637.                           fld:=FDataLink.DataSource.DataSet.Fields[x];
  638.  
  639.                           // Determine field type.
  640.                           ft:=fld.DataType;
  641.                           if (ft=ftBlob) then
  642.                              with TBlobField(fld) do
  643.                              begin
  644.                                   if (BlobType=ftGraphic) or (BlobType=ftTypedBinary) then ft:=ftGraphic
  645.                                   else if (BlobType=ftMemo) or (BlobType=ftFmtMemo) then ft:=ftMemo;
  646.                              end;
  647.  
  648.                           case ft of
  649.                                ftTypedBinary,
  650.                                ftGraphic:
  651.                                   with TWABD_LiveImage(no) do
  652.                                   begin
  653.                                        bmp:=TBitmap.create;
  654.                                        try
  655.                                           bmp.Assign(TBlobField(fld));
  656.                                           Canvas.StretchDraw(Rect(0,0,Width,Height),bmp);
  657.                                        finally
  658.                                           bmp.free;
  659.                                        end;
  660.                                   end;
  661.  
  662.                                ftMemo,ftFmtMemo:
  663.                                   with TWABD_Memo(no) do
  664.                                   begin
  665.                                        Lines.Text:=fld.AsString;
  666.                                        WordWrap:=taOut;
  667.                                   end;
  668.  
  669.                      {$ifndef LEVEL3}
  670.                                ftWideString,ftFixedChar,
  671.                      {$endif}
  672.                                ftString:
  673.                                   with TWABD_Edit(no) do
  674.                                   begin
  675.                                        Text:=fld.AsString;
  676.                                   end;
  677.  
  678.                      {$ifndef LEVEL3}
  679.                                ftLargeInt,
  680.                      {$endif}
  681.                                ftSmallInt,ftInteger,ftWord:
  682.                                   with TWABD_Edit(no) do
  683.                                   begin
  684.                                        Text:=fld.AsString;
  685.                                   end;
  686.  
  687.                                ftBoolean:
  688.                                   with TWABD_CheckBox(no) do
  689.                                   begin
  690.                                        Checked:=TBooleanField(fld).Value;
  691.                                   end;
  692.                           else
  693.                                with TWABD_Label(no) do
  694.                                begin
  695.                                     Caption:='Unsupported field';
  696.                                end;
  697.                           end;
  698.                      end;
  699.                      next;
  700.                 end;
  701.              finally
  702.                 GotoBookmark(bm);
  703.                 FreeBookmark(bm);
  704.              end;
  705.           end;
  706.      end;
  707. end;
  708.  
  709. end.
  710.