Solved

Refreshing appearance of a hint

Posted on 1998-09-04
6
397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

733 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