TCaptionPanel lazarus / 8-Other ---------------------------------------------------------------------- aducom · 2015-03-10 12:53 I'm looking for a TCaptionPanel. Found some old code, but is there a good existing component for that? ---------------------------------------------------------------------- Zoran · 2015-03-10 12:59 Quote from: aducom on March 10, 2015, 01:53:30 pmI'm looking for a TCaptionPanel. Found some old code, but is there a good existing component for that? For what? TPanel has its Caption property. I guess you want something else, but I have no idea what it is. ---------------------------------------------------------------------- aducom · 2015-03-10 13:05 I mean a panel with a header part like a standard window. In Delphi there's a tcaptionpanel for that. Or theaderpanel. ---------------------------------------------------------------------- Ocye · 2015-03-10 13:18 Just place another panel into your parent panel, make it as small you want and align it to top. Et voilá. ---------------------------------------------------------------------- howardpc · 2015-03-10 13:20 I've used this TPanel descendant occasionally. You could adapt it as needed. Code: [Select]unit captionPanel; {$mode objfpc}{$H+} interface uses   Classes, Graphics, ExtCtrls, Controls, LCLIntf; type   { TCaptionPanel }   TCaptionPanel = class(TPanel)   private     FTextLayout: TTextLayout;     procedure SetTextLayout(AValue: TTextLayout);   protected     procedure Paint; override;   public     constructor Create(TheOwner: TComponent); override;   published     property Layout: TTextLayout read FTextLayout write SetTextLayout default tlCenter;   end; implementation { TCaptionPanel } procedure TCaptionPanel.SetTextLayout(AValue: TTextLayout); begin   if FTextLayout=AValue then Exit;   FTextLayout:=AValue;   Invalidate; end; procedure TCaptionPanel.Paint; var   ARect: TRect;   TS : TTextStyle; begin   ARect := GetClientRect;   if (BevelOuter <> bvNone) then     Canvas.Frame3d(ARect, BevelWidth, BevelOuter);   InflateRect(ARect, -BorderWidth, -BorderWidth);   if (BevelInner <> bvNone) then     Canvas.Frame3d(ARect, BevelWidth, BevelInner);   if (Caption <> '') then   begin     TS := Canvas.TextStyle;     TS.Alignment := BidiFlipAlignment(Self.Alignment, UseRightToLeftAlignment);     if BiDiMode<>bdLeftToRight then       TS.RightToLeft:= True;     TS.Layout:= FTextLayout;     TS.Opaque:= False;     TS.Clipping:= False;     TS.SystemFont:=Canvas.Font.IsDefault;     if Enabled then       Canvas.Font.Color := Font.Color     else begin       Canvas.Font.Color := clBtnHighlight;       OffsetRect(ARect, 1, 1);       Canvas.TextRect(ARect, ARect.Left, ARect.Top, Caption, TS);       Canvas.Font.Color := clBtnShadow;       OffsetRect(ARect, -1, -1);     end;     Canvas.TextRect(ARect,ARect.Left,ARect.Top, Caption, TS);   end; end; constructor TCaptionPanel.Create(TheOwner: TComponent); begin   inherited Create(TheOwner);   FTextLayout:=tlCenter; end; end. ---------------------------------------------------------------------- aducom · 2015-03-10 13:38 Tnx, this is the code I found, but it's from 2005. Will try it though. tnx. ---------------------------------------------------------------------- BitBangerUSA · 2015-04-21 17:15 Quote from: aducom on March 10, 2015, 02:38:50 pmTnx, this is the code I found, but it's from 2005. Will try it though. tnx. lol. 2005 a bad year for code?