Tag Archives: findvclwindow

Implement a Close Tab Button for a TTabControl (plus: a round button over hot tab)

Delphi’s TTabControl is a container type VCL control – allowing controls in its client area and displaying a set of tabs (as tabs or buttons). The TTabControl, unlike TPageControl, is not made up of several pages (for each tab), rather the TTabControl has one “page”. By design, the TTabControl is used when displaying/editing list of objects of the same type. When changing the active tab – you need to update the controls it hosts.

An example of a tabbed control UI is an Internet Browser – take a look at Chrome, IE, Edge, or Firefox, etc. tabs. See how each tab has a close button. No such similar close button, to “close a tab”, can be specified or set via properties or methods of the TTabControl. What if you need one (for whatever the purpose)?

So, how to implement a close button for a TTabControl’s Tab? Plus: how to display the close button only over the hot tab (under the mouse) and have the button nicely rounded.
Continue reading