tags:

views:

267

answers:

2

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
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
You can do that using Owner draw.
Gamecat
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
TTextFormat is defined in the file Graphics. So you need to include Graphics in your uses statement.
Gamecat
It's already there. Actually doesn't matter, it's not so necessary as I thought before.
Vlad
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
The rectangle is for the entire control. You should calculate the position of the tab yourself.
Gamecat
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
Solved with using PageControl.Canvas.TextOut(5,5,tx1); Thank you for help, Gamecat
Vlad
+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
+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
Sorry, don't have money for that. It's just a project to help my mother with her work.
Vlad
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
Thank you MarkF, I've already solved this problem with Google and GameCat. I've used a canvas with drawn text on it.
Vlad