?
Solved

Display hint with code, application doesnt have focus

Posted on 1998-10-31
13
Medium Priority
?
733 Views
Last Modified: 2010-04-06
working on a power bar, its a floating bar with buttons,
I need to display the buttons hints even when the application doesnt have focus, but when the mouse is over the control.. seems odd that mouse over fires but the hind is never displayed..

Please help!
0
Comment
Question by:krazy6284
[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
13 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1345232
What is the code you used to show the hint when mouse moves over?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1345233
Hi,

I've the same problem. I even searched through the Delphi code and I finally found: It is not possible to do what you want without changing the Delphi sources (forms.pas/controls.pas) and recompiling them. It's quite annoying, isn't it!?

Regards, Madshi.
0
 
LVL 3

Expert Comment

by:vladika
ID: 1345234
I think the problem lies in the depth of VCL.

When hint timer expired Delphi calls HintTimerExpired procedure
which call ActivateHint procedure.
ActivateHint check: Is your program foreground or not?
If yes Delphi show hint window.
So, you must modify ActivateHint procedure.

1) copy forms.pas into your project directory
2) find in it ActivateHint procedure
3) modify hint firing condition.
i.e source condition is
  if FShowHint and (FHintControl <> nil) and ForegroundTask and
    (FHintControl = GetHintControl(FindDragTarget(CursorPos, True))) then
you would modify as
  if FShowHint and (FHintControl <> nil) and  
    (FHintControl = GetHintControl(FindDragTarget(CursorPos, True))) then
i.e delete call ForegroundTask function
4) rebuild project
5) enjoy :)

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

Expert Comment

by:ZifNab
ID: 1345235
Or you could just call the hints yourself. I've some code here. But maybe vladika's solution is better.

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
 

Expert Comment

by:elkiors
ID: 1345236
I know I'm shoehorning into someone elses question but it's kinda relevant. Does anyone know how to create multiline hints ?

Darren
0
 
LVL 1

Expert Comment

by:venks
ID: 1345237
I am using a component called danhint which shows multi line hints.It is available at Torrys delphi page
venks
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345238
Hello guys!

Vladika: I saw that DanHint and it's pretty cool. I didn't install it, but it seemed quite useful.. There was a demo app, and that's where I took a peek of how it works and so on...


For a multiline hint you could try this one...

Button1.Hint := 'Hello guys! I don''t know what to say. I think this is enough.' + #10#13 +
                          'or probably not . o O Who cares?? =)';

btw- Tom(Zif)'s solution looks fine :-)

Tom: Did you take a look at the website i gave you at your question (to all of you) about that telephony package???

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:vladika
ID: 1345239
Ok. DanHint is pretty cool. But is does not solve krazy6284's problem.
So, let's use DanHint as hint control and my or ZifNab solution to display the hints when the application does not have focus
:)

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1345240
viktor, yes I know of this site and it's translation of TAPI. But I'm looking for some components which implement this translation in a easier way. A component package with all this features like voice, fax, X-modem, Z-modem protocols, ...
0
 

Author Comment

by:krazy6284
ID: 1345241
vladika great idea and works prefect!!

ZifNab nice bit of code there.

Thank you all for your quick comments. however since those were comments I cant give anyone points :(

vladika could you please resubmit your comment as a question.

Regards,
Charlie
0
 
LVL 2

Expert Comment

by:Thaddy
ID: 1345242
This is realy easy, and works like a dream:

procedure TForm1.FormCreate(Sender: TObject);
begin
//Assign a hinthandler  
Application.OnHint:=Processhint;
end;


procedure TForm1.processhint(sender: Tobject);
begin
  statusbar1.simpletext:=Getlonghint(Application.hint);
  //Make shure to call refresh
  refresh;
end;

0
 
LVL 3

Expert Comment

by:vladika
ID: 1345243
Thaddy:
Your solution has some problems:
1) It does not display hint window
2) Hint message appears without delay since it fires in Application.Idle method. And hint window must appears only when hint timer expired, i.e. with small delay.
3) Hint message does not hide automatically after small pause.

Your solution is good to display hint message in status bar, but does not approach to display hint window as krazy6284 wants.

0
 
LVL 3

Accepted Solution

by:
vladika earned 800 total points
ID: 1345244
Solution is below
0

Featured Post

Technology Partners: 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

777 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