Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

Refreshing appearance of a hint

Hello everybody,

   When the cursor is over a control, it displays a hint if ShowHint is true (and there is a hint!). Once the hint has disappeared (the hint timer has expired), it will not reappear until the mouse leaves the control and returns over it to prompt it once again. I have a listbox where I do some fancy hint manipulation according to the index that the mouse point is over. I would like to see the hint reappear every time the mouse stops moving for a moment. With this in mind, I would like a solution that does not involve tricks which I can come up with myself: I want to know what message I can send the listbox, or what I should override in my own custom TAlwaysDisplayHintEvenWhenHintHasAlreadyShown so that this will work.

Regards, and have a particularly good day.

  • 4
  • 2
1 Solution
Hi Edo,

 I'm not sure if it's the same for your case, but if you want to change the appereance of the Hint, you've to make a descendant of THintWindow. I propose that you have a look at its properties etc. There are also a lot of free-source-codes on Torry's, DSP, etc.

 If you still need some more help after that, just ask and I'll help you when I'm back (if I can offcourse), perhaps somebody else can already help you before.

regards, Zif.
Edo082297Author Commented:
Hiya Brad,
  No, I'm happy with the physical appearance of the hint. It's just that the control occupies a large part of the form, and I want the hint to keep reappearing when the mouse hovers over an item in it, and not just once as when the mouse goes over the control and then remains within its constituent rect.

Then, you've to recall the hint again. Or make a descendant that displays longer then the normal hint.

here is a code to let the hint appear and remove it manually :
Is it possible to call the  Hint method directly?
I've a case where I want to click on a Button, and the Hint for
another component (eg, an edit box) will appear for 1 second or
so, and then it will disappear after the button is released. I
saw something like "ActivateHint" but it seemed that I
couldn't make a direct call.
 function RevealHint (Control: TControl): THintWindow;
{ Pops up Hint window for the specified Control, and returns a   }
{ reference to the hint object so it may subsequently be removed }
{ with RemoveHint (see below).                                   }
   ShortHint: string;
   AShortHint: array[0..255] of Char;
   HintPos: TPoint;
   HintBox: TRect;
   { Create the window: }
   Result := THintWindow.Create(Control);

   { Get first half of hint up to '|': }
   ShortHint := GetShortHint(Control.Hint);

   { Calculate Hint Window position & size: }
   HintPos := Control.ClientOrigin;
   Inc(HintPos.Y, Control.Height + 6);    <<<< See note below
   HintBox := Bounds(0, 0, Screen.Width, 0);
       StrPCopy(AShortHint, ShortHint), -1, HintBox,
   OffsetRect(HintBox, HintPos.X, HintPos.Y);
   Inc(HintBox.Right, 6);
   Inc(HintBox.Bottom, 2);

   { Now show the window: }
   Result.ActivateHint(HintBox, ShortHint);
 end; {RevealHint}

 procedure RemoveHint (var Hint: THintWindow);
{ Releases the window handle of a Hint previously popped up with }
{ RevealHint.                                                    }
   Hint := nil;
 end; {RemoveHint}

The line marked <<<< above is the one that positions the hint
window below the control.  This could obviously be altered if
you want a different position for some reason.

Regards, Zif.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


 you know when the mouse moves over the Listbox, you can calculate from there, which item the mouse is on. You can call from there (with the above code) which hint has to appear and you can remove the hint any time you want, or not remove it.

Regards, Zif.
Edo082297Author Commented:
Hi Zif
   Sorry it took so long for me to respond, I have been quite busy with work, we're just about to release a new version. You will be happy to know that a version of your code above made it into the next release. The only suggestion I have is to set the hint color before calling it - hint.color := application.hintcolor. (Off the top of my head). That way the hint appears homogenous with the rest of the application. (That being said, I don't know why it is not the same color as hints appearing in Windows... where is it getting that weird shade of yellow from, or is that just a function of my peculiar settings?)
  Thankyou for your help.


Glad I could help. See you!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now