For some reason when i specify "|" symbol inside Hint string for any Delphi control the hint terminates at the first occurred "|" so the tooltip window contains only part of the text till the first "|" encountered...
I've tested that symbol in C++ (both WinApi + MFC) and it shows hints pretty K with "|" symbol, so it looks like it's some Delphi specific bug.
The whole program works fine but this thing with hints just rly bugs me =\
So, any ideas how to fix that?
This is by design, and is documented behavior:
There are two parts to the Hint string--short and long--separated by the
|
character. Short hints are used by pop-up tool tips. Long hints are used by the status bar. Use theGetShortHint
andGetLongHint
global functions from theControls
unit to extract the long and short hints from a hint string.
To "fix" this so you can display |
characters, you have to either:
use the TApplication.OnShowHint
or TApplicationEvents.OnShowHint
event.
subclass the desired control(s) directly to handle the CM_HINTSHOW
message.
Both are triggered while the pop-up is being prepared, after the Hint
text is split and before the pop-up is actually displayed. Both provide access to a THintInfo
record that you can customize as desired. It has a HintStr
field you can set to whatever text you want, including |
characters. And it has a HintControl
field that points to the control that is displaying the pop-up.
The simplest solution would be to use the OnShowHint
event to set HintStr := HintControl.Hint
.
Using TApplication.OnShowHint
:
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnShowHint := AppShowHint;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Application.OnShowHint := nil;
end;
procedure TForm1.AppShowHint(var HintStr: string; var CanShow: boolean; var HintInfo: THintInfo);
begin
HintStr := HintInfo.HintControl.Hint;
end;
Using TApplicationEvents.OnShowHint
:
procedure TForm1.ApplicationEvents1ShowHint(var HintStr: string; var CanShow: boolean; var HintInfo: THintInfo);
begin
HintStr := HintInfo.HintControl.Hint;
end;