如何在工具栏或者其他的控件上显示其他控件的Hint

TControl.Hint Property

Use the Hint property to provide a string of help text either as a Help Hint, or as help text on a particular location such as a status bar.

A Help Hint is a box containing help text that appears for a control when the user moves the mouse pointer over the control and pauses momentarily. To set up Help Hints:

Specify the Hint property of each control for which a Help Hint should appear.

Set the ShowHint property of each appropriate control to true, or set the ParentShowHint property of all controls to true and set the ShowHint property of the form to true.

At runtime, set the value of the application's ShowHint property to true.

To show the Hint on a status bar or other location, use the OnHint event handler of the application. The application's OnHint event occurs when the mouse pointer moves over the control.

Specify a hint to be used for both a Help Hint box and by an OnHint handler by specifying two values separated by a | character (the vertical bar "or" symbol). For example,

Edit1.Hint := 'Name|Enter Name in the edit box';

Edit1->Hint = "Name|Enter Name in the edit box";


The "Name" part appears in the Help Hint box and the "Enter full name in the edit box" part can be extracted using the GetLongHint function for use in an OnHint event handler.

If Hint contains only one value, the entire string is used as a Help Hint and returned by the GetLongHint function. If a control has no Hint value specified, but its parent control does, the control uses the Hint value of the parent control (as long as the control's ShowHint property is true).

Write an OnHint event handler to perform special processing when the mouse pauses over a control or menu item whose Hint property is not an empty string.

TApplication.OnHint Event

A common use of the OnHint event is to display the value of a control or menu item's Hint property in another control. Note that it is not necessary to use an OnHint event handler to display hints on a status bar (TStatusBar): TStatusBar will automatically display hints if you set its AutoHint property to true.

The Hint property of a control can specify both a short Help Hint and a (usually) longer hint that appears elsewhere because of code in an OnHint event handler.

Note: You can also respond to this event using the TApplicationEvents component, which allows you to assign an event handler using the IDE.
Tip: Component writers can respond to the automatically-fired THintAction action in a component's ExecuteAction method rather than relying on an OnHint event handler.

 

procedure  TMainForm.FormCreate(Sender: TObject); 
begin  
  Application.OnHint :
=  DisplayHint; 
end ;

procedure  TMainForm.DisplayHint(Sender: TObject); 
begin  
  StatusBar1.SimpleText :
=  GetLongHint(Application.Hint) 
end ;

转载于:https://www.cnblogs.com/yunhaisoft/archive/2008/07/10/1239706.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值