Delphi PageControl extra

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!
 
Enjoy!

Add a comment

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

This post's comments feed