Most Windows applications I use in my daily work (email clients, browsers, text editors) have a handy feature allowing to make the text larger by increasing (or smaller by decreasing) the font size. Increasing the text size in a web browser is something I got accustomed to doing frequently – to make the web page easier to read if the default text size was set too small for my eyes.
Even though all applications have some visual way (track bars mainly) to zoom in/out their display – all also support zooming by using (standard?) keyboard shortcuts. CTRL+Plus to increase the font size, CTRL+Minus to decrease. Am not sure if you know, but Delphi IDE unit editor also has this feature.
In a Delphi application, the THintWindow class implements the small pop-up window that appears over a control at run time, when the control has its ShowHint property set to True (and has a value assigned to the Hint property).
The implementation of the THintWindow (at least what gets displayed by it, not how) is rather simple: it will display whatever string value is assigned for the Hint property of a control. If you want more control over what gets displayed by the hint window, and how, and when the hint window will popup – you can create your own version by extending the THintWindow class.
To use your own hint you would assign your own class to the global HintWindowClass variable at application start-up time, so that the new hint window type is used for hints. You can even fine tune the display of the hint window just before it pops-up using the OnHint and OnShowHint events of the TApplicationEvents.
That’s all nice and clear. But, what if the control you are using is Virtual Treeview which has its own version of the hint window implemented in TVirtualTreeHintWindow? What if you want to extend this by including some graphics along with the text that the hint window displays? Further, what if you need to have different hint values for every node displayed by the tree?
Of course, you are not working on a new application – all logic is already there, lots of methods and events already implemented.
The answers: here’s how to simply extend both the TVirtualTreeHintWindow and the TVirtualStringTree to add some node specific graphics to the hint window displaying node specific hints.
I’m a huge fan of one big gem in the Delphi third party controls arena: Virtual Tree View.
Whatever issue I had to solve in my applications harvesting the power of the TVirtualStringTree, the component had the answer, either through vast amount of properties or through nicely exposed events.
The only solution I was not able to find straight forward, or out of the box, is how to have a visual indication that the currently focused node is not visible in the tree. Not “not visible” as hidden but not visible as currently not in view.