Creating custom Hint window
I'm trying to find a way to use my 2nd form as a hint window for a component (for example a TLabel) in my 1st form.
At the moment, I'm exploring the use of THintWindow
and HintWindowClass
, but it is not possible to directly assign a TForm
to HintWindowClass
. Some examples I've seen so far use a TBitmap
which is then drawn on the THintWindow.Canvas
, which is not bad, but I'd still like to use some kind of integrated automatic mechanism.
Another solution that crossed my mind is to m开发者_Python百科anually implement this functionality using OnMouseEnter
, OnMouseMove
and OnMouseLeave
events of the said Tlabel.
If there actually is a way to "assign" a TForm
to HintWindowClass
, I'd like to ask if anyone can provide a code snippet illustrating this. Thanks.
THintWindow
is a descendant of TCustomControl
. TForm
is not a descendant of either of those classes, so you cannot assign any TForm
class to HintWindowClass
. Hint windows need to descend from THintWindow
. Anything you can put on a form you can also put on a THintWindow
. You'll just have to instantiate it manually and assign its Parent
property to make it appear.
The closest you can probably get to "visually" designing a hint window is to design a frame. Make your THintWindow
descendant create an instance of the frame, and then override ActivateHint
(and ActivateHintData
, if you need the data) to forward the hint text and desired size to your frame.
精彩评论