{"id":282686,"date":"2016-12-19T11:30:03","date_gmt":"2016-12-19T08:30:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282686"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282686","title":{"rendered":"Fire-Monkey help and tips"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6e5\/34d\/a03\/6e534da03ee644938f2e830ba8ce0ce8.png\"\/><br \/>  \u0417\u0430 \u0433\u043e\u0434\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Fire-Monkey(FMX) \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0438 \u0435\u0441\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u0441\u044b\u0440\u044b\u043c \u0438 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u044b\u043c, \u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430. <br \/>  \u0414\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0441\u0431\u043e\u0440\u043d\u0438\u043a \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0420\u0430\u0441\u0447\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u043a\u0441\u0442\u0430<\/h3>\n<p>  \u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u044b\u0435, \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439:  <\/p>\n<pre><code class=\"delphi\">function CalcTextSize(Text: string; Font: TFont; Size: Single = 0): TSizeF;<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c.<\/p>\n<p>  <b>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/b>  <\/p>\n<ul>\n<li>Text \u2014 \u0422\u0435\u043a\u0441\u0442<\/li>\n<li>Font \u2014 \u0428\u0440\u0438\u0444\u0442 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u043a\u0441\u0442<\/li>\n<li>Size \u2014 \u0435\u0441\u043b\u0438 0, \u0442\u043e Font.Size \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 Font, \u0438\u043d\u0430\u0447\u0435 \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/li>\n<\/ul>\n<p>  <b>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434:<\/b>  <\/p>\n<pre><code class=\"delphi\">uses   System.Types, FMX.Types, FMX.Graphics, FMX.TextLayout, System.Math, System.SysUtils;  function CalcTextSize(Text: string; Font: TFont; Size: Single = 0): TSizeF; var   TextLayout: TTextLayout; begin   TextLayout := TTextLayoutManager.DefaultTextLayout.Create;   try     TextLayout.BeginUpdate;     try       TextLayout.Text := Text;       TextLayout.MaxSize := TPointF.Create(9999, 9999);       TextLayout.Font.Assign(Font);       if not SameValue(0, Size) then       begin         TextLayout.Font.Size := Size;       end;       TextLayout.WordWrap := False;       TextLayout.Trimming := TTextTrimming.None;       TextLayout.HorizontalAlign := TTextAlign.Leading;       TextLayout.VerticalAlign := TTextAlign.Leading;     finally       TextLayout.EndUpdate;     end;      Result.Width := TextLayout.Width;     Result.Height := TextLayout.Height;   finally     TextLayout.Free;   end; end;<\/code><\/pre>\n<h3>\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430, \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a<\/h3>\n<p>  <\/p>\n<pre><code class=\"delphi\">function FontSizeForBox(Text: string; Font: TFont; Width, Height: Single; MaxFontSize: Single = cMaxFontSize): Integer;<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430, \u0434\u043b\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a.<\/p>\n<p>  <b>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/b>  <\/p>\n<ul>\n<li>Text \u2014 \u0422\u0435\u043a\u0441\u0442<\/li>\n<li>Font \u2014 \u0428\u0440\u0438\u0444\u0442 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u043a\u0441\u0442<\/li>\n<li>Width, Height \u2014 \u0428\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430<\/li>\n<li>MaxFontSize \u2014 \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430<\/li>\n<\/ul>\n<p>  <b>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434:<\/b>  <\/p>\n<pre><code class=\"delphi\">uses   System.Types, FMX.Types, FMX.Graphics, FMX.TextLayout, System.Math, System.SysUtils;  const   cMaxFontSize = 512;  function FontSizeForBox(Text: string; Font: TFont; Width, Height: Single; MaxFontSize: Single = cMaxFontSize): Integer; var   Size, Max, Min, MaxIterations: Integer;   Current: TSizeF; begin   Max := Trunc(MaxFontSize);   Min := 0;    MaxIterations := 20;   repeat     Size := (Max + Min) div 2;      Current := CalcTextSize(Text, Font, Size);      if ((Abs(Width - Current.Width) &lt; 1) and (Width &gt;= Current.Width)) and       ((Abs(Height - Current.Height) &lt; 1) and (Height &gt;= Current.Height)) then       break     else     if (Width &lt; Current.Width) or (Height &lt; Current.Height) then       Max := Size     else       Min := Size;      Dec(MaxIterations);   until MaxIterations = 0;    Result := Size; end;<\/code><\/pre>\n<h3>\u0427\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0441 FindStyleResource \u0438 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c<\/h3>\n<p>  <b>\u0427\u0410\u0412\u041e:<\/b><br \/>  \u041e\u043f\u0438\u0448\u0443 \u00ab\u0431\u0430\u0433\u043e\u0444\u0438\u0447\u0443\u00bb \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0447\u0442\u043e \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0441\u0432\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0439 \u043e\u0442 <b>TStyledControl <\/b>(\u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <b>TStyledControl<\/b>), \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u0442\u0438\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <b>FindStyleResource(&#8216;\u0418\u043c\u044f\u0420\u0435\u0441\u0443\u0440\u0441\u0430&#8217;)<\/b> (\u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 <b>FindStyleResource&lt;\u041a\u043b\u0430\u0441\u0441&gt;(&#8216;\u0418\u043c\u044f\u0420\u0435\u0441\u0443\u0440\u0441\u0430&#8217;, \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f)<\/b>), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <b>TImageControl <\/b>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <b>Image <\/b>\u0442\u0430\u043a:  <\/p>\n<pre><code class=\"delphi\">procedure TImageControl.ApplyStyle; begin   inherited;   if FindStyleResource&lt;TImage&gt;('image', FImage) then     UpdateImage; end;<\/code><\/pre>\n<p>  <b>FindStyleResource <\/b>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u043a\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0441\u0442\u0438\u043b\u044f \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 \u041d\u0415 <b>TStyledControl-\u0430\u0445<\/b>(\u0438 \u0438\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u0445), \u0442\u043e \u0435\u0441\u0442\u044c <b>FindStyleResource <\/b>\u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u043d\u0430 <b>TRectangle<\/b>, \u043d\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u0435\u0433\u043e \u0436\u0435, \u043d\u043e \u043d\u0430 <b>TPanel<\/b>!<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<\/b><br \/>  \u041a\u043e\u0434, \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 <b>ApplyStyle<\/b>:  <\/p>\n<pre><code class=\"delphi\">procedure TEsImageSelection.ApplyStyle; var   T: TControl; begin   inherited ApplyStyle;   if FindStyleResource&lt;TControl&gt;('selection', T) then     ShowMessage('&quot;selection&quot; founded!'); end;<\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434? \u2014 \u041f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0441\u0442\u0438\u043b\u0435\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u044b\u0434\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<p>  <b>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0442\u0438\u043b\u044c:<\/b><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9f1\/b32\/746\/9f1b32746a024d348b96e60808b4ef08.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 <b>A<\/b>, <b>\u00abSelection\u00bb<\/b> \u043b\u0435\u0436\u0438\u0442 \u043d\u0430 <b>\u041d\u0415 <\/b>\u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0435 \u043e\u0442 <b>TStyledControl<\/b>. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e <b>FindStyleResource&lt;TControl&gt;(&#8216;selection&#8217;, T)<\/b> \u043d\u0430\u0439\u0434\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <b>Selection<\/b>.<\/p>\n<p>  \u0412 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 <b>B<\/b>, \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0441 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0447\u0442\u043e <b>FindStyleResource&lt;TControl&gt;(&#8216;selection&#8217;, T)<\/b> \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <b>Selection<\/b>!<\/p>\n<p>  <b>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a?<\/b><\/p>\n<p>  \u0421\u0443\u0434\u044f \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c \u043f\u043e\u0438\u0441\u043a \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 <b>TStyledControl<\/b>-\u0430\u0445 \u0441\u043b\u043e\u043c\u0430\u043d \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0434\u0430\u0431\u044b \u043d\u0435 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u043b\u0438 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0433\u043b\u044e\u043a\u0438\\\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.(\u043d\u043e \u044f \u043d\u0435 \u0438\u0437\u0443\u0447\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0441\u0442\u0438\u043b\u0435\u0439 \u2014 \u043a\u0440\u043e\u043c\u0435\u0448\u043d\u044b\u0439 \u0430\u0434, \u0441 \u043d\u0430\u0441\u043b\u0430\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u0438 <b>Fire-Monkey<\/b> \u0440\u0430\u0437\u043d\u044b\u0445 \u043b\u0435\u0442).<\/p>\n<p>  <b>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443?<\/b><\/p>\n<p>  \u041f\u0443\u0442\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <b>EsFindStyleResource<\/b>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u0441\u0442\u0438\u043b\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 <b>FindStyleResource<\/b>. <\/p>\n<pre><code class=\"delphi\">function EsFindStyleResource(Self: TStyledControl; StyleName: string): TFmxObject;<\/code><\/pre>\n<p>  <b>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/b>  <\/p>\n<ul>\n<li>Self \u2014 TStyledControl<\/li>\n<li>StyleName \u2014 \u0418\u043c\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/li>\n<\/ul>\n<p>  <b>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434:<\/b>  <\/p>\n<pre><code class=\"delphi\">type   TOpenStyledControl = class(TStyledControl);  function EsFindStyleResource(Self: TStyledControl; StyleName: string): TFmxObject; var   StyleObject: TFmxObject; begin   \/\/ \u0435\u0441\u043b\u0438 Self.ChildrenCount &lt; 1 \u0442\u043e \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0441\u0442\u0438\u043b\u044c,   \/\/ \u0442.\u043a. \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0447\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u044d\u043b\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0438\u043b\u044f \u0412\u0421\u0415\u0413\u0414\u0410 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u043d\u0443\u043b\u0435\u0432\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443.   if (TOpenStyledControl(Self).ResourceLink = nil) or (Self.ChildrenCount &lt; 1) then     Exit(nil);    StyleObject := nil;    Self.Children[0].EnumObjects(     function (Obj: TFmxObject): TEnumProcResult     begin       if Obj.StyleName.ToLower = StyleName.ToLower then       begin         Result := TEnumProcResult.Stop;         StyleObject := Obj;       end else         Result := TEnumProcResult.Continue;     end);    Result := StyleObject; end;<\/code><\/pre>\n<h3>\u0420\u0438\u0441\u043a\u0438(Ticks) \u0443 TTrackBar<\/h3>\n<p>  \u0412 <b>Fire-Monkey<\/b> \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <b>TTrackBar <\/b>\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u00ab\u0440\u0438\u0441\u043a\u0438\u00bb, \u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <b>DrawTicks <\/b>\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u00ab\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u00bb \u0432 <b>FMX <\/b>\u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c.<br \/>  \u0424\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 <b>OnPainting <\/b>\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <b>TTrackBar<\/b>.<\/p>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/b><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e0d\/371\/07c\/e0d37107c1ee4d988dd10a8ba4371791.png\"\/><\/p>\n<pre><code class=\"delphi\">procedure DrawTicks(Control: TTrackBar; Offset: Single; PageSize: Single; DrawBounds: Boolean;   LineKind: TLineKind; LineWidth, LineSpace: Single; Color: TAlphaColor);<\/code><\/pre>\n<p>  <b>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/b>  <\/p>\n<ul>\n<li>Control \u2014 TTrackBar \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0440\u0438\u0441\u043a\u0438<\/li>\n<li>Offset \u2014 \u0421\u0434\u0432\u0438\u0433 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430<\/li>\n<li>PageSize \u2014 \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0440\u0438\u0441\u043a\u0430\u043c\u0438<\/li>\n<li>DrawBounds \u2014 \u0420\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u0440\u0438\u0441\u043a\u0438<\/li>\n<li>LineKind \u2014 \u0422\u0438\u043f \u043b\u0438\u043d\u0438\u0439 (TLineKind = (Up, Down, Left, Right, Both))<\/li>\n<li>LineWidth \u2014 \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438<\/li>\n<li>LineSpace \u2014 \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043b\u0438\u043d\u0438\u0438<\/li>\n<li>Color \u2014 \u0426\u0432\u0435\u0442 \u043b\u0438\u043d\u0438\u0439<\/li>\n<\/ul>\n<p>  <b>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434:<\/b>  <\/p>\n<pre><code class=\"delphi\">type   TLineKind = (Up, Down, Left, Right, Both);  procedure DrawTicks(Control: TTrackBar; Offset: Single; PageSize: Single; DrawBounds: Boolean;   LineKind: TLineKind; LineWidth, LineSpace: Single; Color: TAlphaColor); var   Obj: TFmxObject;   Cnt: TControl;   L: TPointF;   Coord, RealCoord: Single;    function GetCoord(Value: Single): Single;   begin     if Control.Orientation = TOrientation.Horizontal then       Result := Ceil(THTrackBar(Control).GetThumbRect(Value).CenterPoint.X)\/\/  + Crutch     else       Result := Ceil(THTrackBar(Control).GetThumbRect(Value).CenterPoint.Y);\/\/  + Crutch;   end;    procedure DrawLine(Coord: Single);   begin     if Control.Orientation = TOrientation.Horizontal then     begin       if (SameValue(LineSpace, 0)) and (LineKind = TLineKind.Both) then       begin         Control.Canvas.DrawLine(           PointF(Coord + 0.5, L.Y + Trunc(Cnt.Height \/ 2) - LineWidth + 0.5),           PointF(Coord + 0.5, L.Y + Trunc(Cnt.Height \/ 2) + LineWidth - 0.5), 1)       end else       begin         if (LineKind = TLineKind.Down) or (LineKind = TLineKind.Both) then           Control.Canvas.DrawLine(             PointF(Coord + 0.5, L.Y + Trunc(Cnt.Height \/ 2) + LineSpace + 0.5),             PointF(Coord + 0.5, L.Y + Trunc(Cnt.Height \/ 2) + LineSpace + LineWidth - 0.5), 1);         if (LineKind = TLineKind.Up) or (LineKind = TLineKind.Both) then           Control.Canvas.DrawLine(             PointF(Coord + 0.5, L.Y + Trunc(Cnt.Height \/ 2) - LineSpace - 0.5),             PointF(Coord + 0.5, L.Y + Trunc(Cnt.Height \/ 2) - LineSpace - LineWidth + 0.5), 1);       end;     end else     begin       if (SameValue(LineSpace, 0)) and (LineKind = TLineKind.Both) then       begin         Control.Canvas.DrawLine(           PointF(L.X + Trunc(Cnt.Width \/ 2) - LineWidth + 0.5, Coord + 0.5),           PointF(L.X + Trunc(Cnt.Width \/ 2) + LineWidth - 0.5, Coord + 0.5), 1)       end else       begin         if (LineKind = TLineKind.Right) or (LineKind = TLineKind.Both) then           Control.Canvas.DrawLine(             PointF(L.X + Trunc(Cnt.Width \/ 2) + LineWidth + 0.5, Coord + 0.5),             PointF(L.X + Trunc(Cnt.Width \/ 2) + LineWidth + LineWidth - 0.5, Coord + 0.5), 1);         if (LineKind = TLineKind.Left) or (LineKind = TLineKind.Both) then           Control.Canvas.DrawLine(             PointF(L.X + Trunc(Cnt.Width \/ 2) - LineWidth - 0.5, Coord + 0.5),             PointF(L.X + Trunc(Cnt.Width \/ 2) - LineWidth - LineWidth + 0.5, Coord + 0.5), 1);       end;     end;   end;  begin   if Control.Orientation = TOrientation.Horizontal then     Obj := Control.FindStyleResource('htrack')   else     Obj := Control.FindStyleResource('vtrack');    if Obj = nil then     Exit;    Cnt := Obj.FindStyleResource('background') as TControl;   if Cnt = nil then     Exit;    Control.Canvas.Stroke.Thickness := 1;   Control.Canvas.Stroke.Kind := TBrushKind.Solid;   Control.Canvas.Stroke.Color := Color;    L := Cnt.LocalToAbsolute(PointF(0, 0)) - Control.LocalToAbsolute(PointF(0, 0));   if DrawBounds and not SameValue(Offset, 0.0) then     DrawLine(GetCoord(Control.Min));    Coord := Offset + Control.Min;   while Coord &lt;= Control.Max - Control.Min do   begin     if (Coord &gt;= Control.Min) and (Coord &lt;= Control.Max) then     begin       RealCoord := GetCoord(Coord);       DrawLine(RealCoord);     end;     Coord := Coord + PageSize;   end;    if DrawBounds and not SameValue(GetCoord(Control.Max), GetCoord(Coord - PageSize)) then     DrawLine(GetCoord(Control.Max)); end;<\/code><\/pre>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0434\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \ud83d\ude42<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/317814\/\"> https:\/\/habrahabr.ru\/post\/317814\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6e5\/34d\/a03\/6e534da03ee644938f2e830ba8ce0ce8.png\"\/><br \/>  \u0417\u0430 \u0433\u043e\u0434\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Fire-Monkey(FMX) \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0438 \u0435\u0441\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u0441\u044b\u0440\u044b\u043c \u0438 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u044b\u043c, \u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430. <br \/>  \u0414\u0430\u043d\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0441\u0431\u043e\u0440\u043d\u0438\u043a \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-282686","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=282686"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282686\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}