Question

Delphi IDE's "code completion" feature includes a second flyout window with code parameters - the one on the right: enter image description here

An interesting feature of that window is that it is automatically sized to fit the content. What parameters must be used to create a window like that, and how can the automatic sizing be achieved in Delphi (XE)?

Était-ce utile?

La solution

I would call that a hint window. Sizing "automatically" is done by code, and not by parameters alone, unless those parameters are properties in components, and the components then take on the work of auto-sizing to fit the content. In fact, that's probably what you want.

You could do it all yourself in Raw Win32 API terms... But it's a lot of work. Sizing a window to fit text can be done, using a window without a border and with style WS_POPUP set, and by painting it all yourself, and using the DrawTextEx API which can return the size of the text, but the simpler approach would be to use a hint window component, some of which will let you size them based on the content inside them. Unless you have a real need to reinvent the wheel, there are lots of hint window components already written. Use one.

I have used, and can recommend the hint window components from TMS (commercial) and JEDI JVCL (free), and they can both do window hints much like the above. The TMS Html Hint and TMS Office hint components are both capable of result similar to the above.

If you need a free solution, TJvHintWindow, built into the JVCL doesn't have as much functionality as the TMS ones, but could be tweaked and modified with a little work, to do something much like the picture you've shown.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top