I want to improve the look of my app by TPagecontrols with rounded cornes like the one used by the DELPHI IDE itself. How can I do this ????
Asked
Active
Viewed 895 times
1
-
1Use the `TTabSet` control as Delphi IDE does. – TLama Feb 14 '14 at 18:33
-
You can override the `PaintWindow` method of the `TPageControl` to paint the tab as you want. – RRUZ Feb 14 '14 at 18:43
-
I wrote my own tab control, much like the one in Google Chrome – Jerry Dodge Feb 14 '14 at 19:08
-
You can draw your own custom tabs as has been done in this question http://stackoverflow.com/questions/18282728/make-owner-drawn-tpagecontrol-tabs-look-nicer-like-without-owner-draw – Graymatter Feb 14 '14 at 20:09
1 Answers
3
The Delphi IDE uses a TTabSet component. A big difference between TPageControl and TTabSet is TTabSet does not automatically change between different views of controls the way a TPageControl does. You need to update the display manually when the tab is clicked.
You could override the painting of the TPageControl tabs to make them look like the TTabSet tabs. However you can also easily hide the tabs on the page control and add a TTabSet control to switch between the pages of the PageControl.
Here is some example code for doing that. In the form create add any pages from the page control to the TabSet and hide the individual tabs on the Page Control. Then in the TabSet OnChange event switch the active page on the PageControl.
procedure TForm3.FormCreate(Sender: TObject);
var
i: integer;
begin
for i := 0 to PageControl1.PageCount - 1 do
begin
TabSet1.Tabs.Add(PageControl1.Pages[i].Caption);
PageControl1.Pages[i].TabVisible := false;
end;
TabSet1.TabIndex := 0;
end;
procedure TForm3.TabSet1Change(Sender: TObject; NewTab: Integer;
var AllowChange: Boolean);
begin
PageControl1.ActivePageIndex := NewTab;
end;

Mark Elder
- 3,987
- 1
- 31
- 47