2014-01-26 81 views
-1

在Windows默認外觀中,製表符標題顯示爲水平(從左到右1),並且啓用了VCL樣式,它們以垂直方式顯示(從頂部到頂部[2]) 。我如何解決這個問題在Delphi XE5上? 細節:我使用JEDI-VCL 3.58中的JvgPageControl組件。JvgPageControl上的左對齊Tabsheets Delphi + Vcl樣式已啓用問題

我想創建一個DisplayFusion歡迎屏幕的類似界面[3]。歡迎提出建議!

圖片:

enter image description here

提前感謝!

+0

我想有一個無國界的頁面控件沒有任何明顯的標籤通過一組圖像控制它(看標籤)。 – TLama

回答

1

的TJvgPageControl使用TPageControl控制的相同VCL風格鉤(TTabControlStyleHook),所以你必須創建一個從TTabControlStyleHook繼承了新的風格鉤和覆蓋DrawTab方法。

檢查這個基本實現新樣式鉤

type 
    TTabControlStyleHookExt = class(TTabControlStyleHook) 
    protected 
    procedure DrawTab(Canvas: TCanvas; Index: Integer); override; 
    end; 

    TCustomTabControlClass = class(TCustomTabControl); 

{ TTabControlStyleHookExt } 

procedure TTabControlStyleHookExt.DrawTab(Canvas: TCanvas; Index: Integer); 
var 
    R, LayoutR, GlyphR: TRect; 
    ImageWidth, ImageHeight, ImageStep : Integer; 
    LDrawState: TThemedTab; 
    LDetails: TThemedElementDetails; 
    ThemeTextColor: TColor; 
    FImageIndex: Integer; 
begin 
    if TabPosition <> tpLeft then 
    begin 
    inherited ; 
    exit; 
    end; 

    if (Images <> nil) and (Index < Images.Count) then 
    begin 
    ImageWidth := Images.Width; 
    ImageHeight := Images.Height; 
    ImageStep := 3; 
    end 
    else 
    begin 
    ImageWidth := 0; 
    ImageHeight := 0; 
    ImageStep := 0; 
    end; 

    R := TabRect[Index]; 
    if R.Left < 0 then Exit; 

    if Index = TabIndex then 
    Dec(R.Left, 2) 
    else 
    Dec(R.Right, 2); 

    Canvas.Font.Assign(TCustomTabControlClass(Control).Font); 
    LayoutR := R; 

    if Index = TabIndex then 
    LDrawState := ttTabItemLeftEdgeSelected 
    else if (Index = HotTabIndex) and MouseInControl then 
    LDrawState := ttTabItemLeftEdgeHot 
    else 
    LDrawState := ttTabItemLeftEdgeNormal; 

    LDetails := StyleServices.GetElementDetails(LDrawState); 
    StyleServices.DrawElement(Canvas.Handle, LDetails, R); 

    { Image } 
    if Control is TCustomTabControl then 
    FImageIndex := TCustomTabControlClass(Control).GetImageIndex(Index) 
    else 
    FImageIndex := Index; 

    if (Images <> nil) and (FImageIndex >= 0) and (FImageIndex < Images.Count) then 
    begin 
    GlyphR := LayoutR; 

    GlyphR.Bottom := GlyphR.Bottom - ImageStep; 
    GlyphR.Top := GlyphR.Bottom - ImageHeight; 
    LayoutR.Bottom := GlyphR.Top; 
    GlyphR.Left := GlyphR.Left + (GlyphR.Right - GlyphR.Left) div 2 - ImageWidth div 2; 

    if StyleServices.Available then 
     StyleServices.DrawIcon(Canvas.Handle, LDetails, GlyphR, Images.Handle, FImageIndex); 
    end; 

    { Text } 

    if StyleServices.GetElementColor(LDetails, ecTextColor, ThemeTextColor) then 
    Canvas.Font.Color := ThemeTextColor; 

    //use the top tab style to draw the text 
    if Index = TabIndex then 
     LDetails := StyleServices.GetElementDetails(ttTabItemSelected) 
    else 
    if (Index = HotTabIndex) and MouseInControl then 
     LDetails := StyleServices.GetElementDetails(ttTabItemHot) 
    else 
     LDetails := StyleServices.GetElementDetails(ttTabItemNormal); 

    DrawControlText(Canvas, LDetails, Tabs[Index], LayoutR, DT_VCENTER or DT_CENTER or DT_SINGLELINE or DT_NOCLIP); 
end; 

然後註冊新的樣式鉤這樣

initialization 
    TStyleEngine.RegisterStyleHook(TJvgPageControl, TTabControlStyleHookExt); 

enter image description here