Center the text vertically in a TEdit lazarus / 31-LCL ---------------------------------------------------------------------- pmesquita · 2022-06-28 02:08 Guys, Is there any way to center the text vertically in a TEdit without the borders (BorderStyle=bsnone) ? Because without the borders the text is always on top of the control... I've been reading that the Windows message WM_NCCALCSIZE changes the internal area of TEdit but this message is simply not sent to TEdit.. Windows Message Post https://forum.lazarus.freepascal.org/index.php?topic=24595.0 ---------------------------------------------------------------------- ASerge · 2022-06-28 17:15 Quote from: pmesquita on June 28, 2022, 04:08:23 amIs there any way to center the text vertically in a TEdit without the borders (BorderStyle=bsnone) ? It's easier to put TEdit on a TPanel with a clWindow color without borders and the desired size. And then vertically align TEdit inside TPanel. 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 uses Windows; procedure VCenterControlInsideParentByTextHeight(Control: TWinControl);   function GetWindowTextHeight(Wnd: HWND): Integer;  var    DC: HDC;    TM: TTextMetric;  begin    DC := GetWindowDC(Wnd);    try      if not GetTextMetrics(DC, TM) then        RaiseLastOSError;    finally      ReleaseDC(Wnd, DC);    end;    Result := TM.tmHeight;  end; var  R: TRect;  Extra: Integer;begin  R := Control.BoundsRect;  Extra := R.Height - GetWindowTextHeight(Control.Handle);  if Extra <= 0 then    Exit;  R.Inflate(0, -Extra div 2);  Control.BoundsRect := R;end; procedure TForm1.Button1Click(Sender: TObject);begin  VCenterControlInsideParentByTextHeight(Edit1);end;