我这个控件是继承TSpeedButton类的,只是想有一个Parameters属性。
  TDyHotQry = class(TSpeedButton)
  private
    FParameters : TParameters;
       ...
  protected
  public
    constructor Create(AOwner : TComponent); override;
       ...
  published
    property Parameters : TParameters read FParameters write SetParamsList;
       ...
  end;
constructor TDyHotQry.Create(AOwner : TComponent);
begin
   inherited Create(AOwner);
   Glyph.LoadFromResourceName(HInstance,'TDyHOTQRY');
       ...
   FParameters   := TParameters.Create(a1,a2); {输入/输出参数}
       ...
end;就是上面的a1,a2两个参数该怎么写。我乱写了很多,都不行,后来用FParameters   := TParameters.Create(self,TParameter);生成控件后,我在用的过程中提示错误“invalid class typecast ” 这是怎么回事呢?

解决方案 »

  1.   

    TParameters; 是专门给Ado用的。
      

  2.   

    那你继承speedbutton用这个属性干吗?
      

  3.   

    想做一个按钮,直接点击它,就可以出现一个对话框,里面出现一个TADOQUERY类查询出来的值
      

  4.   

    TParameters 隶属于 ADODB,是个数据库相关可以在这里用吗?
      

  5.   

    但我用TParams就行啊,为什么用TParameters却不行
      

  6.   

    unit dyHotQry;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics,ADODB, Controls, Forms, Dialogs,
      Buttons, DBTables, DB,DyQry,DBGrids,Variants;type  THotQryParam = class;
      // 热键查询控件
      TDyHotQry = class(TSpeedButton)
      private
        FCode   : string;
        FLang   : string;
        FQryValue : Variant;
        FQuery  : TDyQuery;
        FParams : TParams;
        FAllowExit : Boolean;
        FHotQryParam : THotQryParam;
        procedure SetQryValue(Value : Variant);
        procedure SetParamsList(Value: TParams);
        procedure SetHotQryParam(Value : THotQryParam);
      protected
      public
        property Lang : string read FLang write FLang;
        property Query : TDyQuery read FQuery write FQuery;
        function RunQry(TheEvent : String): boolean; //启动Hot Form
        constructor Create(AOwner : TComponent); override;
        destructor  Destroy; override;
        function ExitOrClick(TheEvent : String) : boolean;
      published
        property AllowExit : boolean read FAllowExit write FAllowExit;
        property Code : string read FCode write FCode;
        property Visible  default False;
        property NumGlyphs default 2;
        property Flat default True;
        procedure Click; override;
        property Params : TParams read FParams write SetParamsList;
        property QryValue : Variant read FQryValue write SetQryValue;
        property HotQryParam : THotQryParam read FHotQryParam write SetHotQryParam;
      end;  THotQryParam = class(TPersistent)
      private
        FQryName         : String;
        FQryTable        : TStrings;
        FqryListFields   : TStrings;
        FqryQueryFields  : TStrings;
        FqryResultFields : TStrings;
        FqryFilter       : TStrings;    procedure SetQryName(Value: String);
        procedure SetQryTable(Value: TStrings);
        procedure SetqryListFields(Value: TStrings);
        procedure SetqryQueryFields(Value: TStrings);
        procedure SetqryResultFields(Value: TStrings);
        procedure SetqryFilter(Value: TStrings);
      public
        constructor Create; virtual;
        destructor  Destroy; override;
      published
        Property QryName  : String read Fqryname write SetQryName;
        Property QryTable : TStrings read FqryTable write SetQryTable;
        Property QryListFields : TStrings read FqryListFields write SetqryListFields;
        Property QryQueryFields : TStrings read FqryQueryFields write SetqryQueryFields;
        Property QryResultFields : TStrings read FqryResultFields write SetqryResultFields;
        Property QryFilter : TStrings read FqryFilter write SetqryFilter;
      end;
    constructor TDyHotQry.Create(AOwner : TComponent);
    begin
       inherited Create(AOwner);
       Query:=dydb.dmPBDb1.Qry_temp;
       {从资源文件中取出图标}
       Glyph.LoadFromResourceName(HInstance,'TDyHOTQRY');
       Visible   := False;
       NumGlyphs := 1;
       Flat      := True;
       AllowExit := false;
       ShowHint  := true;
       FQryValue := '';
       Hint      := 'Press F2 Query' ;
       FParams   := TParams.Create(Self); {输入/输出参数}
       FHotQryParam := THotQryParam.Create;{列示字段,查询字段等......}
    end;怎么把上面的    FQuery  : TdyQuery;
        FParams : TParams;
    改成    FQuery  : TadoQuery;
        FParams : TParameters;