Is there any possibility to orient left aligned tab captions horizontally?
+3
A:
Not sure what you want exactly, but you can set the OwnerDraw property to True. And use the OnDrawTab event to draw it yourself.
Gamecat
2009-06-25 10:28:47
I want to make captions on tabs to be horizontal. Just like on the image below. I've tried to use Gerry's suggestion "set Canvas.Font.Orientation to 900 or 2700" as PageControl.Canvas.Font.Orientation := 900; but I get "Undeclared identifier: 'Orientation'http://img341.imageshack.us/img341/9533/56692119.jpg
Vlad
2009-06-25 10:59:50
You can do that using Owner draw.
Gamecat
2009-06-25 11:28:31
In my TForm1.PageControl2DrawTab section I put code that ulrichb suggested in http://stackoverflow.com/questions/769285/how-can-i-change-the-orientation-of-the-label-on-a-tpagecontrol. Compiler stops compilation on TextFormat: TTextFormat; saying Undeclared identifier: 'TTextFormat'. I'm new to Delhi, would you please tell me how to correct this?
Vlad
2009-06-25 12:12:43
TTextFormat is defined in the file Graphics. So you need to include Graphics in your uses statement.
Gamecat
2009-06-25 12:47:27
It's already there. Actually doesn't matter, it's not so necessary as I thought before.
Vlad
2009-06-25 13:14:40
Uhm, here's my code for DrawTab property. For some reason it draws canvas on every tab but text appears only on the first. Can't get why. Would you suggest a solution please?var PageControl: TPageControl; Text: string; tr1: TRect;begin PageControl := Control as TPageControl; Text := PageControl.Pages[TabIndex].Caption; tr1 := Rect; PageControl.Canvas.TextRect(tr1,5,5,Text);end;
Vlad
2009-06-25 13:43:52
The rectangle is for the entire control. You should calculate the position of the tab yourself.
Gamecat
2009-06-25 14:05:34
But everytime I put text on the canvas: PageControl.Canvas.TextRect(tr1,5,5,Text);PageControl.Canvas.TextRect(tr1,5,20,Text);previous text disappears. Am I doing something wrong?
Vlad
2009-06-25 14:15:46
Solved with using PageControl.Canvas.TextOut(5,5,tx1); Thank you for help, Gamecat
Vlad
2009-06-25 14:56:45
+3
A:
Besides using ownerdraw I don't think there is an easy way to do that with the TPageControl. If you'd consider using a non-free third party component, I use the TRzPageControl from Raize Components and it has this feature. Make sure to set the "TextOrientation" to horizontal and the TabStyle to roundcorners (the default tab style looks odd with the text on horizontal mode).
MarkF
2009-06-25 11:07:47
+1 It doesn't take many of these requirements before a suite of well-crafted tools like Raize Components to pay for themselves many times over. Ray continues to support them actively, updating with each Delphi update while maintaining multiple versions of backward compatibility.
Argalatyr
2009-06-25 11:45:52
Sorry, don't have money for that. It's just a project to help my mother with her work.
Vlad
2009-06-25 12:13:36
Perhaps if it isn't a "pro" level app, you could use a pagecontrol with no visible tab and use another control (or a set of buttons) to change the active page. If the number of pages is fixed then it's very easy, if not you'd just need to dynamically create the buttons (which is also very easy.) I'm sure you could get a pretty good look by playing around with different controls to change the pages.
MarkF
2009-06-25 15:55:02
Thank you MarkF, I've already solved this problem with Google and GameCat. I've used a canvas with drawn text on it.
Vlad
2009-06-25 18:09:48