Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to force a hint (tooltip)

59 views
Skip to first unread message

Pieter van Erp

unread,
Dec 30, 2000, 10:48:00 AM12/30/00
to
Hello all,

I am looking for a way to force a control's hint to appear.

I am using the system-icon biHelp for context-help, and I know how to
find out what control the user clicked on. But I cannot get the hint to
popup.

Anybody...

--

Pieter van Erp

" It ain't over 'till the Fat Lady sings"


Alles over Gevechtsvliegtuigen: http://gevechtsvliegtuigen.cjb.net

Viktor Litovchenko

unread,
Dec 30, 2000, 3:13:48 PM12/30/00
to

Hi, Pieter van Erp <p.v.erp@bigfoot*NOSPAM*.com>! You wrote:

> Hello all,
>
> I am looking for a way to force a control's hint to appear.
>
> I am using the system-icon biHelp for context-help, and I know how to
> find out what control the user clicked on. But I cannot get the hint to
> popup.

Set the control's property ShowHint to true. And set the hint message to a
Hint property.

Viktor.


Pieter van Erp

unread,
Dec 31, 2000, 7:59:11 AM12/31/00
to
In article <92lfr4$2a0q$1...@gavrilo.mtu.ru>, cort...@mtu-net.ru says...

Thanks for your answer, but I think you misunderstood. I want the hint to
popup when I say it should, not when the user hovers his mouse over the
control.

BTW, I am using Delphi 4.0 C/S

Viktor Litovchenko

unread,
Dec 31, 2000, 1:57:22 PM12/31/00
to
Hi, Pieter van Erp <p.v.erp@bigfoot*NOSPAM*.com>! You wrote:

> Thanks for your answer, but I think you misunderstood. I want the hint to
> popup when I say it should, not when the user hovers his mouse over the
> control.

Excuse me. I'm not sure, maybe it's not the optimal way, but it works. I use
THintWindow class for it. For example, i show a hint window on a Button2
when i press Button1:

procedure TForm1.Button1Click(Sender: TObject);
var R:TRect;
HW:THintWindow;
begin
HW:=THintWindow.Create(Button2);
HW.Color:=Application.HintColor;
R:=HW.CalcHintRect(255,Button2.Hint,nil);
R.Left:=R.Left+Form1.Left+Button2.Left;
R.Right:=R.Right+Form1.Left+Button2.Left;
R.Top:=R.Top+Form1.Top+Button2.Top;
R.Bottom:=R.Bottom+Form1.Top+Button2.Top;
HW.ActivateHint(R,Button2.Hint);
Application.ProcessMessages;
Sleep(Application.HintPause);
HW.ReleaseHandle;
end;

Of course you may use other pause value or even release hint by special
command. Excuse me again. Happy New Year!

Viktor.


AlanGLLoyd

unread,
Jan 1, 2001, 12:04:49 PM1/1/01
to
In article <92nvo5$16l6$1...@gavrilo.mtu.ru>, "Viktor Litovchenko"
<cort...@mtu-net.ru> writes:

>begin
> HW:=THintWindow.Create(Button2);
> HW.Color:=Application.HintColor;
> R:=HW.CalcHintRect(255,Button2.Hint,nil);

// ClientToScreen helps all that maths <gg>
R.TopLeft := Button2.ClientToScreen(Point(0, 0));
R.BottomRight := Button2.ClientToScreen(Point(0 + R.Right, 0 + R.Bottom));

(*


> R.Left:=R.Left+Form1.Left+Button2.Left;
> R.Right:=R.Right+Form1.Left+Button2.Left;
> R.Top:=R.Top+Form1.Top+Button2.Top;
> R.Bottom:=R.Bottom+Form1.Top+Button2.Top;

*)


> HW.ActivateHint(R,Button2.Hint);
> Application.ProcessMessages;
> Sleep(Application.HintPause);
> HW.ReleaseHandle;
>end;

And, of course on every TControl descendant there is also ScreenToClient().

Alan Lloyd
alang...@aol.com

Viktor Litovchenko

unread,
Jan 1, 2001, 12:54:15 PM1/1/01
to
Hi, AlanGLLoyd <alang...@aol.com>! You wrote:

> // ClientToScreen helps all that maths <gg>
> R.TopLeft := Button2.ClientToScreen(Point(0, 0));
> R.BottomRight := Button2.ClientToScreen(Point(0 + R.Right, 0 +
R.Bottom));
>

Oh, thanks! It really helps.

Viktor.


Viktor Litovchenko

unread,
Jan 1, 2001, 2:06:51 PM1/1/01
to
Hi, AlanGLLoyd <alang...@aol.com>

> R.TopLeft := Button2.ClientToScreen(Point(0, 0));
> R.BottomRight := Button2.ClientToScreen(Point(0 + R.Right, 0 +
R.Bottom));

2 Pieter: but it's better to write

R.TopLeft := Button2.ClientToScreen(Point(0, 0-R.Bottom));
R.BottomRight := Button2.ClientToScreen(Point(R.Right,0));

To show the hint above the control.

Viktor

Pieter van Erp

unread,
Jan 2, 2001, 2:08:47 PM1/2/01
to
In article <92qkm6$2tbd$1...@gavrilo.mtu.ru>, cort...@mtu-net.ru says...

Thanks, it works great.

By the way, I use Mouse.CursorPos.X en CursorPos.Y to calculate the
coordinates of the window.

0 new messages