[solved] Panel capiton vertical alignment (good only for version 2.2.4) lazarus / 31-LCL ---------------------------------------------------------------------- Nicole · 2023-01-07 11:08 There was a version of fp, which allowed to set "vertical alignement" to a panles' captions in Laz 2.2.2 I attach the 2 files I used, unfortunately they do not work any more in 2.2.4. How to bring my panels' caption to align to the top? ---------------------------------------------------------------------- wp · 2023-01-07 13:56 https://forum.lazarus.freepascal.org/index.php/topic,60007.msg448026.h tml#msg448026: "Note that this is a new feature and thus will not be backported to Laz-fixes." In other words, the first release version in which the TPanel will have this property will be v2.4. ---------------------------------------------------------------------- Nicole · 2023-01-07 15:11 thank you for the reply. Why does the fix not work any more (copy the files)? I really have used a lot of panels in my old Delphi and this thing means a lot of work to me. ---------------------------------------------------------------------- jamie · 2023-01-07 16:32 something like this ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,LclIntF,lclType; type   { TForm1 }   TForm1 = class(TForm)    Panel1: TPanel;    procedure Panel1Paint(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Panel1Paint(Sender: TObject);Var  R:TRect;  S:String;begin  if Sender Is Tpanel then  With TPanel(Sender) DO   Begin     Canvas.Brush.Color := Brush.color;     R := ClientRect;     Canvas.FillRect(R);     S := Caption;     DrawText(Canvas.Handle,Pchar(S),Length(S),R,DT_TOP or DT_CENTER or DT_WORDBREAK);   end;end; end.  Don't know what you are doing with the rest of it however, you can use a single handler for all the panels. ---------------------------------------------------------------------- wp · 2023-01-07 16:54 Quote from: Nicole on January 07, 2023, 04:11:43 pmWhy does the fix not work any more (copy the files)? If you use Laz 2.2.4 or older it should never have worked because it is a new feature and thus is not backported to releases or the fixes branch. Of course you could have changed the files yourself, it is not difficult: Open file extctrls.pp (in the lcl folder). Find TCustomPanel and add "FVertAlignment: TVerticalAlignment;" and "procedure SetVerticalAlignment(const AValue: TVerticalAlignment);" and "property VertAlignment: TVerticalAlignment read FVertAlignment write SetVertAlignment default taVerticalCenter;" to the private section. Find TPanel and add "property VertAlignment;" to the published section.Open file "custompanel.inc" (in the lcl/include folder).Find the code for "TCustomPanel.Create" and add "FVertAlignment := taVerticalCenter;" after "FAlignment := ..."Add the setter procedure "TCustomPanel.SetVertAlignment":Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCustomPanel.SetVertAlignment(const Value: TVerticalAlignment);begin  if FVertAlignment <> Value then  begin    FVertAlignment := Value;    Invalidate;  end;end;Find procedure "TCustomPanel.Paint"At the top add the declaration "const VerticalAlignmentToTextLayout: array[TVerticalAlignment] of TTextLayout = (tlTop, tlBottom, tlCenter);"A few lines down replace "TS.Layout := tlcenter" by "TS.Layout:= VerticalAlignmentToTextlayout[FVertAlignment];"To have the new property at designtime you must rebuild the IDE.You probably had done this for Laz 2.2.2 and then made a new installation, maybe with v2.2.4, and thus your changes are lost - this is problem with hand-made changes in release files... ---------------------------------------------------------------------- Nicole · 2023-01-07 18:04 thank you so much for talking time to post this. Up to now I failed, unfortunately with the very first element (I followed all the instructions), but could not re-compile. I read extctrls.pp(1069,74) Error: Unknown class field or method identifier "SetVertAlignment" for this text   TCustomPanel = class(TCustomControl)   private     FVertAlignment: TVerticalAlignment;  // die ersten 3 Zeilen fügt ich am 7.1.2023 ein     procedure SetVerticalAlignment(const AValue: TVerticalAlignment);     property VertAlignment: TVerticalAlignment read FVertAlignment write SetVertAlignment default taVerticalCenter; ---------------------------------------------------------------------- wp · 2023-01-07 18:29 Sorry, typos on my side: /1/ Use "procedure SetVertAlignment(const AValue: TVerticalAlignment)" rather than "SetVerticalAlignment(...)". /2/ Put the "property VertAlignment: TVerticalAlignment read FVerticalAlignment write SetVertAlignment default taVerticalCenter" into the protected section! ---------------------------------------------------------------------- Nicole · 2023-01-10 17:06 unfortunately this did not work neither. I lost sight what to change where. Would be great to download those files somewhere. what I tried, - see other topic of mine / ours. ---------------------------------------------------------------------- wp · 2023-01-10 18:15 I patched the extctrls.pp and custompanel.inc of v2.2.4 with the changes needed for TVertAlignment from Laz/main and am attaching the files as zip. Make a backup copy of the original v2.2.4 files and unzip the attachment over the originals. Be careful with the folders: extctrls.pp must go into the lcl folder, and custompanel.inc must go into lcl/include. Rebuild the IDE. But be warned: The new property VertAlignment will be gone if a new version 2.2.6 will be released. And do not use the patched files in any other installation, it will probably not work and might make these IDEs unusable. The safest way to work with new features is to use the official main branch from GitLab. Learn how to build an IDE from these sources manually, or use FPCUpdeluxe to get this done automatically. ---------------------------------------------------------------------- Nicole · 2023-01-10 18:52 Thank you so very much! It works again! I am aware, that an upgrade would destroy my patch. And additionally: need me all panels to be corrected by hand to "aligntop". What I do not understand is about the versions: I was convinced, that the 2.2.4 would contain the new property already. And then I was convinced, that the git-rep of 2.2.4 would contain files, which "fit" to my 2.2.4 installation. Both were false. Why that? ---------------------------------------------------------------------- wp · 2023-01-10 19:11 Quote from: Nicole on January 10, 2023, 07:52:08 pmI was convinced, that the 2.2.4 would contain the new property already. All changes normally are added to the git "main" branch. Bug fixes are back-ported to "fixes", but not "new features". From time to time the current state of "fixes" is tagged with a new three-digit version number, and this is when a new bug-fix release version evolves. In our nomenclature, the third version number (the "4" in 2.2.4) indicates a bug-fix release. From this sequence it follows that  the bug-fix releases usually do not contain "new features". When the first or second number changes, however, new features are included. This is created from tagging the main branch. The next "new feature" release will be v2.6.0 (or 3.0.0). Adding a new property to a component, per se, IS a new feature. Therefore the initial changes in "main" in which the VertAlignment property was added will not make it into the 2.2.x releases, and will first appear officially in v2.6 or v3.0. Quote from: Nicole on January 10, 2023, 07:52:08 pmAnd then I was convinced, that the git-rep of 2.2.4 would contain files, which "fit" to my 2.2.4 installation. Yes, the release installer of v2.2.4 takes its files from 2.2.4 git repo which usually will never be changed any more. ---------------------------------------------------------------------- Nicole · 2023-01-10 19:40 Thank you!