Solved

Display hint with code, application doesnt have focus

Posted on 1998-10-31
13
707 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
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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 200 total points
ID: 1345244
Solution is below
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 161
Create Database on Android via Delphi dbExpress 3 112
Performance of SQL statement 37 127
Convert MS Word document to a PDF file 9 91
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…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 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