Solved

Display hint with code, application doesnt have focus

Posted on 1998-10-31
13
655 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
Comment Utility
What is the code you used to show the hint when mouse moves over?
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
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
Comment Utility
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
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
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
Comment Utility
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
Comment Utility
I am using a component called danhint which shows multi line hints.It is available at Torrys delphi page
venks
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 10

Expert Comment

by:viktornet
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Solution is below
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 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

13 Experts available now in Live!

Get 1:1 Help Now