In a Delphi 10.3.3 Windows VCL Application, in the OnHint event-handler of a TApplicationEvents component, I show the current hint in the status-bar:
procedure TForm1.ApplicationEvents1Hint(Sender: TObject);
begin
statMain.SimpleText := Application.Hint;
end;
However, I would like to add some specific text containing specific run-time data depending on which control sends the hint.
Unfortunately, the Sender parameter does not give that information.
So how can I detect which control has sent the hint?
The
OnHintevent does not provide access to any information about the control that is displaying the hint.However, the
OnShowHintevent does, and you can fully customize the hint however you want in that event:The
HintInfoprovides all kinds of information about the hint that you can customize:Also, FYI, you don't need to use the
TApplication(Event).OnHintevent just to display theTApplication.Hinttext in aTStatusBar. If you set the StatusBar'sAutoHintproperty to true then the StatusBar can displayTApplication.Hintupdates automatically. You just need to make sure that you don't have anOnHinthandler assigned, otherwiseAutoHintwill not work (OnShowHintis fine, though).