如何在工具栏或者其他的控件上显示其他控件的Hint
2008-07-10 09:34
489 查看
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;
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;
相关文章推荐
- C# 解决panel或者其他控件叠加时,此控件背景透明,显示的背景色为窗体背景色问题
- Jquery和Js如何在页面触发回车事件(或者其他html控件)
- C#如何在Panel或者GroupBox控件中自由地切换其他窗体
- jQuery里面的datepicker日期控件默认是显示英文的,如何显示中文或其他语言呢?
- jQuery里面的datepicker日期控件默认是显示英文的,如何显示中文或其他语言呢?
- 如何:使用 Windows 窗体 TextBox 控件创建密码文本框 .NET Framework 2.0 其他版本 密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符。 创
- QT,其他类中计算出的结果如何在ui界面的控件中显示?
- VC 中的IP地址控件,关联一个DWORD的变量dwValue,如何将这个dwValue按IP地址显示转化成4个数字或者字符串?
- 在Vs2008中创建的用户控件,在工具栏中如何显示
- 如何获取taskflow的id值,用于控制当前页面的控件显示或隐藏
- 如何在Mobile程序中显示其他程序的图标
- 如何在ImagePickerController中只显示图片或者视频?(既视频和图片的筛选)
- 如何动态调整控件大小和隐藏控件显示
- Timer控件如何不被其他窗体的代码所影响
- 关于Oracle中查询的数字值的显示格式需要保留小数点后两位(或者三位,及其他位数)
- Android自定义PopupWindow显示在控件上方或者下方
- 如何在工具栏上添加平面下拉控件
- 如何控制层在某个时间显示或者隐藏
- 如何控制其他程序窗体上的窗口控件
- Ajax Accordion控件中如何控制回传回来时仍然显示刚才选中的项