自己定义了一个类,如何给这个类加上hint属性?

解决方案 »

  1.   

    加上hint属性不难,关键是怎么实现showhint这个方法,
    查查forms.pas,看看到底是怎么实现的。
    麻烦呀,还不如继承呢。
      

  2.   

    不过可以试下继承其它组件的.hint,看看是否可以使用。
      

  3.   

    我觉得从TWinControl继承下来比较好,直接用hint和Showhint的属性就可以了。
      

  4.   

    TControl类和GRID类才具有hint属性吧?继承下来不行吗?
      

  5.   

    function TCustomAction.DoHint(var HintStr: string): Boolean;
    begin
      Result := True;
      if Assigned(FOnHint) then FOnHint(HintStr, Result);
    end;其实HINT属性无非是要SHOWHINT的,而就要用到DOHINT,但具体任何实现我也不清楚。
      

  6.   

    Occurs when the mouse pauses over a client control or menu item.type THintEvent = procedure (var HintStr: String; var CanShow: Boolean) of object;
    property OnHint: THintEvent;只知道这些了!
      

  7.   

    //希望对你有帮助unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      a = procedure;
      pa = ^a;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Edit1: TEdit;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
        CustomHint: THintWindow;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      Self.CustomHint := THintWindow.Create(Self);
      Self.CustomHint.Parent := Self;
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      Self.CustomHint.Free;end;procedure TForm1.Button1Click(Sender: TObject);
    var
      Pt: TPoint;
    begin
      Self.CustomHint.Caption := Self.Edit1.Text;
      GetCursorPos(Pt);
      Self.CustomHint.Top := Pt.Y;
      Self.CustomHint.Left := Pt.X;
      Self.CustomHint.Show;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      Self.CustomHint.Hide;
    end;end.
      

  8.   

    type
      a = procedure;
      pa = ^a;
    这几行不要用。呵...这只是一个显示提示的程序。而其它的就用一个最简单的方法就是判断鼠标事件,也可以用其它的方法..
      

  9.   

    其实完全可以从 TControl 继承来实现.