How to show Vista style balloon hints in Delphi?

后端 未结 3 695
谎友^
谎友^ 2021-02-03 13:50

On input validation, I\'m using balloon tips instead of message boxes. My problem is that on Vista, they have the old XP style with the rounded corners, not the newer more recta

3条回答
  •  生来不讨喜
    2021-02-03 14:16

    The TCustomHint in Delphi 2009 has four protected overloads of ShowHint that when called allow you to place the TCustomHint on demand and in specific locations:

    procedure ShowHint; overload;
    procedure ShowHint(Point: TPoint); overload;
    procedure ShowHint(Rect: TRect); overload;
    procedure ShowHint(Control: TControl); overload;
    

    All you need to do is implement a hint in the style you want (or just descend from TBalloonHint if it is close enough) and make those methods public to have the ability to place a hint where-ever and when-ever you want.

    Note: Change the Title property of the TCustomHint to change what text is displayed, unless you use the ShowHint that takes a TControl as an argument. In that case it gets it from the control's Hint property (and places it in the Title property of the TCustomHint).

提交回复
热议问题