2016-03-08 65 views
2

Delphi XE-6自定義Firemonkey樣式 - 鏈接控件和樣式之間的屬性?

我想創建我自己的TGroupBox控件的樣式。

我看了很多演示和教程,但似乎無法找出這一個。

如何使控件中的文本變爲空白並顯示在樣式的文本控件上?

我知道它與StyleName有關,但我不知道我做錯了什麼。

有人可以提供一個簡單的例子嗎? 例如,一個TGroupbox - 在頂部有一個標題,但是如果你想在橫幅上從頂部開始,它會怎樣。創建我可以做的橫幅,但是我怎樣才能將橫幅上的文本項目與控件的標題屬性相鏈接?

thanx

回答

4

您不必自己進行鏈接。

的FireMonkey控制自己做:

function TPresentedTextControl.FindTextObject: TFmxObject; 
begin 
    Result := FindStyleResource('text'); // Do not localize 
end; 

確保您的範本:文本控件被命名爲text

我做了一個小例子是這樣的:

enter image description here

object TStyleContainer 
    object TLayout 
    StyleName = 'grouboxstylebottom' 
    Padding.Left = 2.000000000000000000 
    Padding.Top = 8.000000000000000000 
    Padding.Right = 2.000000000000000000 
    Padding.Bottom = 2.000000000000000000 
    Position.X = 410.000000000000000000 
    Position.Y = 360.000000000000000000 
    Size.Width = 120.000000000000000000 
    Size.Height = 100.000000000000000000 
    Size.PlatformDefault = False 
    Visible = False 
    TabOrder = 0 
    object TStyleObject 
     StyleName = 'background' 
     Align = Client 
     CapMode = Tile 
     Locked = True 
     SourceLookup = 'Windows 10 Desktopstyle.png' 
     Size.Width = 116.000000000000000000 
     Size.Height = 90.000000000000000000 
     Size.PlatformDefault = False 
     WrapMode = Tile 
     SourceLink = < 
     item 
      CapInsets.Left = 2.000000000000000000 
      CapInsets.Top = 2.000000000000000000 
      CapInsets.Right = 2.000000000000000000 
      CapInsets.Bottom = 2.000000000000000000 
      SourceRect.Left = 166.000000000000000000 
      SourceRect.Top = 83.000000000000000000 
      SourceRect.Right = 213.000000000000000000 
      SourceRect.Bottom = 130.000000000000000000 
     end> 
     object TPanel 
     StyleName = 'banner' 
     Align = Bottom 
     Position.Y = 70.000000000000000000 
     Size.Width = 116.000000000000000000 
     Size.Height = 20.000000000000000000 
     Size.PlatformDefault = False 
     TabOrder = 0 
     end 
     object TText 
     StyleName = 'text' 
     Align = Bottom 
     ClipParent = True 
     Locked = True 
     HitTest = False 
     Margins.Left = 1.000000000000000000 
     Margins.Top = 2.000000000000000000 
     Margins.Right = 1.000000000000000000 
     Margins.Bottom = -15.000000000000000000 
     Position.X = 1.000000000000000000 
     Position.Y = 70.146484375000000000 
     Size.Width = 114.000000000000000000 
     Size.Height = 14.853515625000000000 
     Size.PlatformDefault = False 
     Text = 'Groupbox' 
     TextSettings.Font.Family = 'Showcard Gothic' 
     TextSettings.WordWrap = False 
     end 
    end 
    end 
end 

所以最終的控制將是這樣的:

enter image description here

設置你的分組框中的StyleLookup在這種情況下爲groupboxstylebottom

+0

啊,明白了!正是我在找什麼 - 謝謝! – JakeSays