Delphi PageControl extra (updated 2019.11.29)

With this little unit I snipped together you can add close buttons on tabs and also rearrange them with drag-and-drop on a standard TPageControl component.
Without any 3rd party components, you can add all the above functionalities to a standard TPageControl component. The problem is - I found no place where this was already done.
The only challenge is that OwnerDraw is not exactly working when Styles are active and the OnDrawTab will never trigger. For that we need to create Style Hooks, and these two will work completely separate.
  • Our TPageControl application
  • Our TPageControl application with Styles
  • Now let's use PageControlExtra...
  • PageControlExtra without styles
  • PageControlExtra with styles
The installation is rather easy - just add uPageControlExtra to your uses list, and change TPageControl definitions to uPageControlExtra.TPageControl. Optionally you can assign a TNotifyEvent to the OnClosePage variable in the unit, so you can execute some special code instead of simply .Free-ing the closed tabs.
You should consider increasing the tab widths, otherwise the close button might cover the text!
Update 2019.11.02:
- Unit no longer applies to PageControls which are not uPageControlExtra.TPageControls
- Rearranging tabs with drag-and-drop now shows the tab image while dragging
Update 2019.11.29:
- Fixed an issue when wrong pages were closed if page control contained hidden tabsheets

Add a comment

HTML code is displayed as text and web addresses are automatically converted.

This post's comments feed