home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d6 / RX275D6.ZIP / Units / RxDBReg.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-24  |  4KB  |  138 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         Delphi VCL Extensions (RX)                    }
  4. {                                                       }
  5. {         Copyright (c) 1995, 1996 AO ROSNO             }
  6. {         Copyright (c) 1997, 1998 Master-Bank          }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. { Note:
  11.   - in Delphi 5.0 you must add DCLRX5 to the requires page of the
  12.     package you install this components into.
  13.   - in Delphi 4.0 you must add DCLRX4 to the requires page of the
  14.     package you install this components into.
  15.   - in Delphi 3.0 you must add DCLRXCTL to the requires page of the
  16.     package you install this components into.
  17.   - in C++Builder 4.0 you must add DCLRX4 to the requires page of the
  18.     package you install this components into.
  19.   - in C++Builder 3.0 you must add DCLRXCTL to the requires page of the
  20.     package you install this components into. }
  21.  
  22. unit RxDBReg;
  23.  
  24. {$I RX.INC}
  25. {$D-,L-,S-}
  26.  
  27. interface
  28.  
  29. uses Classes, RTLConsts, DesignIntf, DesignEditors, VCLEditors, SysUtils, DB;
  30.  
  31. { Register data aware custom controls and components }
  32.  
  33. procedure Register;
  34.  
  35. implementation
  36.  
  37. {$IFDEF WIN32}
  38.  {$R *.D32}
  39. {$ELSE}
  40.  {$R *.D16}
  41. {$ENDIF}
  42.  
  43. uses TypInfo, RXLConst, RXDBCtrl, RXLookup, RxLogin, RXDBComb, VCLUtils,
  44.   {$IFNDEF RX_D3} DBTables, {$ENDIF} {$IFDEF DCS} SelDSFrm, {$ENDIF} 
  45.   {$IFDEF RX_D3} RxMemDS, {$ENDIF} {$IFDEF WIN32} DBRichEd, {$ENDIF} 
  46.   Consts, LibHelp, RxDsgn;
  47.  
  48. { TRxFieldProperty }
  49. { For TRxDBLookupList, TRxDBLookupCombo components }
  50.  
  51. type
  52.   TRxFieldProperty = class(TRxDBStringProperty)
  53.   public
  54.     procedure GetValueList(List: TStrings); override;
  55.     function GetDataSourcePropName: string; virtual;
  56.   end;
  57.  
  58. function TRxFieldProperty.GetDataSourcePropName: string;
  59. begin
  60.   Result := 'LookupSource';
  61. end;
  62.  
  63. procedure TRxFieldProperty.GetValueList(List: TStrings);
  64. var
  65.   Instance: TComponent;
  66.   PropInfo: PPropInfo;
  67.   DataSource: TDataSource;
  68. begin
  69.   Instance := TComponent(GetComponent(0));
  70.   PropInfo := TypInfo.GetPropInfo(Instance.ClassInfo, GetDataSourcePropName);
  71.   if (PropInfo <> nil) and (PropInfo^.PropType^.Kind = tkClass) then
  72.   begin
  73.     DataSource := TObject(GetOrdProp(Instance, PropInfo)) as TDataSource;
  74.     if (DataSource <> nil) and (DataSource.DataSet <> nil) then
  75.       DataSource.DataSet.GetFieldNames(List);
  76.   end;
  77. end;
  78.  
  79. {$IFDEF DCS}
  80. {$IFDEF RX_D3}
  81.  
  82. { TMemoryDataEditor }
  83.  
  84. type
  85.   TMemoryDataEditor = class(TMemDataSetEditor)
  86.   protected
  87.     function CopyStructure(Source, Dest: TDataSet): Boolean; override;
  88.   end;
  89.  
  90. function TMemoryDataEditor.CopyStructure(Source, Dest: TDataSet): Boolean;
  91. begin
  92.   Result := Dest is TRxMemoryData;
  93.   if Result then
  94.     TRxMemoryData(Dest).CopyStructure(Source);
  95. end;
  96.  
  97. {$ENDIF RX_D3}
  98. {$ENDIF DCS}
  99.  
  100. { Designer registration }
  101.  
  102. procedure Register;
  103. begin
  104.  
  105. {$IFDEF RX_D4}
  106.   { Database Components are excluded from the STD SKU }
  107.   if GDAL = LongWord(-16) then Exit;
  108. {$ENDIF}
  109.  
  110. { Data aware components and controls }
  111.   RegisterComponents(LoadStr(srRXDBAware), [
  112.     {$IFDEF RX_D3} TRxMemoryData, {$ENDIF}
  113.     TRxDBGrid, TRxDBLookupList, TRxDBLookupCombo, TRxLookupEdit, TDBDateEdit, 
  114.     TRxDBCalcEdit, TRxDBComboEdit, {$IFDEF WIN32} TRxDBRichEdit, {$ENDIF}
  115.     TDBStatusLabel, TRxDBComboBox]);
  116.   RegisterComponents(LoadStr(srRXTools), [TRxLoginDialog]);
  117. {$IFDEF RX_D3}
  118.   RegisterNonActiveX([TRxMemoryData, TRxDBGrid, TDBDateEdit, 
  119.     TDBStatusLabel, TRxDBComboBox, TRxDBLookupList,
  120.     TRxDBLookupCombo, TRxLookupEdit, TRxDBComboEdit, TRxDBCalcEdit, 
  121.     TRxDBRichEdit, TCustomDBComboBox, TRxLookupControl, TRxLoginDialog], 
  122.     axrComponentOnly);
  123. {$ENDIF RX_D3}
  124. { Property and component editors for data aware components }
  125.   RegisterPropertyEditor(TypeInfo(string), TRxLookupControl, 'LookupField',
  126.     TRxFieldProperty);
  127.   RegisterPropertyEditor(TypeInfo(string), TRxLookupEdit, 'LookupField',
  128.     TRxFieldProperty);
  129. {$IFDEF RX_D3}
  130.   RegisterPropertyEditor(TypeInfo(Integer), TRxDBGrid, 'RowsHeight', nil);
  131. {$IFDEF DCS}
  132.   RegisterComponentEditor(TRxMemoryData, TMemoryDataEditor);
  133. {$ENDIF DCS}
  134. {$ENDIF RX_D3}
  135.  
  136. end;
  137.  
  138. end.