Z nadejściem IE3 (comctrl32 wersja 4.70) TabControl i PageControl otrzymały możliwość umieszczania zakładek na każdej krawędzi. Te nowe style mogą być dodane w czasie pracy programu, ale przy poziomym umieszczeniu nie ulegną obróceniu fonty. Najlepiej więc stworzyć własny komponent wywodzący się z TTabControl albo TPageControl.
//-------------------------------------------------- //w nagłówku: #ifndef MyTabControlH #define MyTabControlH //-------------------------------------------------- #include <vcl\SysUtils.hpp> #include <vcl\Controls.hpp> #include <vcl\Classes.hpp> #include <vcl\Forms.hpp> #include <vcl\ComCtrls.hpp> //-------------------------------------------------- #define TCS_VERTICAL 0x0080 #define TCS_RIGHT 0x0002 #define TCS_BOTTOM 0x0002 //--------------------------------------------------- enum TTabOrientation {toBottom, toLeft, toRight, toTop}; class TMyTabControl : public TTabControl { private: TTabOrientation FTabOrientation; void __fastcall SetTabOrientation(TTabOrientation Value); protected: virtual void __fastcall CreateParams(TCreateParams &Params); public: __fastcall TMyTabControl(TComponent* Owner); __published: __property TTabOrientation TabOrientation = {read = FTabOrientation, write = SetTabOrientation}; }; //------------------------------------------------------ #endif //------------------------------------------------------ //w pliku źródłowym: #include <vcl\vcl.h> #pragma hdrstop #include "MyTabControl.h" //------------------------------------------------------- static inline TMyTabControl *ValidCtrCheck() { return new TMyTabControl(NULL); } //------------------------------------------------------- __fastcall TMyTabControl::TMyTabControl(TComponent* Owner) : TTabControl(Owner) { } //------------------------------------------------------- void __fastcall TMyTabControl::CreateParams(TCreateParams &Params) { TTabControl::CreateParams(Params); switch (FTabOrientation) { case toBottom: Params.Style = Params.Style | TCS_BOTTOM; break; case toLeft: Params.Style = Params.Style | TCS_VERTICAL | TCS_MULTILINE; MultiLine = true; break; case toRight: Params.Style = Params.Style | TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHT; MultiLine = true; break; } } //------------------------------------------------------- void __fastcall TMyTabControl::SetTabOrientation(TTabOrientation Value) { if (FTabOrientation != Value) { FTabOrientation = Value; RecreateWnd(); } } //------------------------------------------------------- namespace Mytabcontrol { void __fastcall Register() { TComponentClass classes[1] = {__classid(TMyTabControl)}; RegisterComponents("Samples", classes, 0); } } |