Recent

Author Topic: Can I stylise TTabControl tabs  (Read 2534 times)

FRex

  • New Member
  • *
  • Posts: 20
Can I stylise TTabControl tabs
« on: October 19, 2017, 12:45:28 am »
I'm using a TTabControl and I'd like to style each tab (the thing on the top, not the page/content) on it's own, mainly the background and/or text color, nothing else. Is there a way to do that? This is to mark duplicate tabs with same query opened in a program I'm making. I could use something else like adding a * or some other symbol to the text but I'd prefer this for clarity and visual appeal.
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: Can I stylise TTabControl tabs
« Reply #1 on: October 19, 2017, 03:48:31 am »
The TabControl has an Event "OnDrawTab" that gives you the tab index and Rectangle
need to custom draw the tab..
 
 You'll need to experiment of course but it gives you the chance to draw a custom
looking tab, text color ect

EDIT:
 Just looking at the Windows target, it seems the OwnerDraw options does not
work? Hmm...

 There Is the CusttomDrawn package that has a tabcontrol that does, you need to install it, its in the list of packages that are not yet installed.
« Last Edit: October 19, 2017, 03:57:10 am by jamie »
The only true wisdom is knowing you know nothing

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Can I stylise TTabControl tabs
« Reply #2 on: October 19, 2017, 05:50:30 am »
Me too, cannot make it works on Linux.

Maybe the TS can consider ATTabs:
http://wiki.freepascal.org/ATTabs

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: Can I stylise TTabControl tabs
« Reply #3 on: October 19, 2017, 06:49:54 pm »
Looking at the code, it was never implemented or taken out..

 The property to enable it is there and the OnCustomDraw event is defined
but, there is no code in the paint handler to implement it nor does it even
test for the assignment of the event.
 
 Now I come from the windows world and I could implement that without too much
pain. All I need to do is override the paint handler in my code or actually  implement
the needed code in the existing TtabControl class.

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018