问题描述
我需要为特定控件(而不是整个应用程序)创建自定义提示窗口(具有自己的颜色和布局)
I need to create a custom hint window (with it's own color and layout) for a specific control (not the entire application)
提示文本本身不会被连接到特定的提示
属性控件。
The hint text itself will not be connected to that specific Hint
property control.
根据建议,我为写了一个处理程序CM_HINTSHOW
(如果控件具有 ShowHint = True
,则可以正常工作):
As suggested I wrote a handler for CM_HINTSHOW
(This worked if the Control has ShowHint=True
):
procedure TMyControl.CMHintShow(var Message: TMessage);
begin
Form1.caption := 'x';
// Here I will display my own Hint window
// inherited;
end;
但是现在,我如何知道何时/何处隐藏提示超时了吗? CM_HINTSHOW
或 CM_HINTSHOWPAUSE
都没有提供此信息。
But now, how do I know when/where to hide it when the hint times out? neither CM_HINTSHOW
or CM_HINTSHOWPAUSE
gives me this info.
推荐答案
在您的 CM_HINTSHOW
消息处理程序中,可以将 lParam
值转换为 PHintInfo
指针,然后根据需要自定义其字段。例如,仅更改背景颜色,请设置 THintInfo.HintColor
字段。要更改提示的布局,可以从 THintWindow
派生一个新类,并将该类类型分配给 THintInfo.HintWindowClass
字段。
In your CM_HINTSHOW
message handler, you can cast the lParam
value to a PHintInfo
pointer and then customize its fields as needed. For instance, to simply change the background color, set the THintInfo.HintColor
field. To change the layout of the hint, you can derive a new class from THintWindow
and assign that class type to the THintInfo.HintWindowClass
field.
让VCL为您管理提示,包括显示和隐藏提示。
Let the VCL manage the hint for you, including showing and hiding it.
这篇关于如何为特定控件创建自己的自定义提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!