I am using Lazarus v0.9.30 (32 bit compiler).
I have the following code that I use to show the hint text stored in the object associated with a TColumnTitle object in a TStringGrid.
procedure TTmMainForm.TmApplicationPropertiesShowHint
(
var HintStr: string;
var CanShow: boolean;
var HintInfo: THintInfo
);
var
aGrid : TStringGrid;
aColumnTitle : TTmColumnTitle;
aRow : integer;
aColumn : integer;
begin
aRow := 0;
aColumn := 0;
HintInfo.HintMaxWidth := 200;
HintInfo.HideTimeout := 10000;
HintInfo.HintColor := $00D7FBFA;
//Get a pointer to the current grid.
aGrid := TStringGrid(HintInfo.HintControl);
//Find out what cell the mouse is pointing at.
aGrid.MouseToCell(HintInfo.CursorPos.X, HintInfo.CursorPos.Y, aColumn, aRow);
if ((aRow = 0) and (aColumn < aGrid.ColCount)) then
begin
//Get the object associated with the column title.
aColumnTitle := TTmColumnTitle(aGrid.Objects[aColumn, aRow]);
//Define where the hint window will be displayed.
HintInfo.CursorRect := aGrid.CellRect(aColumn, aRow);
//Display the hint.
HintStr := Trim(aColumnTitle.stHint);
end; {if}
end;
I have access to the HintInfo object and want to use it to change the fontsize of the hint text. The HintInfo object provides access to HintInfo.HintControl.Font but using this changes the font of all the cell text in the underlying TStringGrid. The HintInfo object also provides access to Hintinfo.HintWindowClass.Font, but you are unable to access Font.Size. Is there a way to modify the font size of the hint?
There’s the
TScreen.HintFontproperty which is intended for this purpose, however it seems to me wrong in its getter. One thing I can say at this time, it doesn’t work as expected.And since you don’t have an access to the hint window instance, the best what you can do is to subclass the common hint window class.
In the following example I’ve created the custom hint window class where you can specify the font size by passing the size value through
HintInfo.HintDatawhich was currently unused.Here’s a screenshot how it looks like: