Solved

Refreshing appearance of a hint

Posted on 1998-09-04
6
393 Views
Last Modified: 2010-04-04
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.

Edo
0
Comment
Question by:Edo082297
  • 4
  • 2
6 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1338633
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.
0
 
LVL 1

Author Comment

by:Edo082297
ID: 1338634
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.

Edo
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1338635
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.
A:
 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).                                   }
{----------------------------------------------------------------}
 var
   ShortHint: string;
   AShortHint: array[0..255] of Char;
   HintPos: TPoint;
   HintBox: TRect;
 begin
   { 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);
   DrawText(Result.Canvas.Handle,
       StrPCopy(AShortHint, ShortHint), -1, HintBox,
       DT_CALCRECT or DT_LEFT or DT_WORDBREAK or DT_NOPREFIX);
   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.                                                    }
{----------------------------------------------------------------}
 begin
   Hint.ReleaseHandle;
   Hint.Free;
   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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1338636
Edo,

 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.
0
 
LVL 1

Author Comment

by:Edo082297
ID: 1338637
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.

Regards,
Edo



0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1338638
Glad I could help. See you!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 117
code issue 8 85
Using idhttp to login to instagram 2 65
find a node in VST 2 47
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now