Board index » delphi » Couple of questions

Couple of questions

Here's a couple of issues I ran into with a component I'm developing. I'm
hoping someone else has solved them, or at least found out that they're
"unsolvable" :-)

1. Is there a definitive way to give a control focus, even if it's (say) on a
non-visible tab sheet? At present I have to bail out if Control.CanFocus
returns False, but it'd be nice to force the control's parent (and its parent,
and its parent) to the front so that the control does indeed gain focus.

2. Hint windows. I'm popping a hint up using THintWindow.ActivateHint, and
using a TTimer to close it using ReleaseHandle. Is there a way I can tell the
hint to disappear if a key is pressed, or if the user switches to another app?
At the moment the hint stays there for a few seconds, even if I've Alt+Tabbed
to another application.

TIA,
Mab

 

Re:Couple of questions


Quote
Mab wrote:
> 1. Is there a definitive way to give a control focus, even if it's
(say) on a
> non-visible tab sheet? At present I have to bail out if
Control.CanFocus
> returns False, but it'd be nice to force the control's parent (and its
parent,
> and its parent) to the front so that the control does indeed gain

focus.

No idea. Sorry.

Quote
> 2. Hint windows. I'm popping a hint up using THintWindow.ActivateHint,
and
> using a TTimer to close it using ReleaseHandle. Is there a way I can
tell the
> hint to disappear if a key is pressed, or if the user switches to
another app?
> At the moment the hint stays there for a few seconds, even if I've
Alt+Tabbed
> to another application.

I wasn't aware of the existance of the THintWindow class. One learns new
things every day...

Looking at the help for THintWindow it seems to me as if you might wan't
to override IsHintMsg with your own function and check for any keyboard
press messages or task-switching messages (do such a thing exists?).

I used to "fake" a hint with a TPanel when requering greater control of
the hints. Maybe you could do the same. Set the Panels Visible to false
and change the color to clInfoBk and font color to clInfoText. Then you
can control the "hint" by simply setting the Top,Left and Visible
properties of the TPanel. If THintWindow approach don't work, maybe you
can use such a fake "hint" together with OnKeyPress or OnKeyDown events?

Regards

Nicolai Buch-Andersen
ni...@mip.sdu.dk

Other Threads