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
> 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.
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
> 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.
>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
> // 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.
> 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
Thanks, it works great.
By the way, I use Mouse.CursorPos.X en CursorPos.Y to calculate the
coordinates of the window.