[SOLVED] Form resize bsNone lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2025-11-19 09:11 Hello, I would like to ask more experienced forum users if there is another way to scale the borderstyle:= bsNone form that does not cause the form to freeze when scaling faster. 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 function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam): LRESULT; stdcall;const  Margin = 5;var  Rect: TRect;  MouseX, MouseY: LongInt;begin  if uMsg = WM_NCHITTEST then  begin    Result := Windows.DefWindowProc(Ahwnd, uMsg, wParam, lParam);    MouseX := GET_X_LPARAM(lParam);    MouseY := GET_Y_LPARAM(lParam);    with Rect do    begin      Left := MouseX - Form1.BoundsRect.Left;      Right := Form1.BoundsRect.Right - MouseX;      Top := MouseY - Form1.BoundsRect.Top;      Bottom := Form1.BoundsRect.Bottom - MouseY;      if (Top < Margin) and (Left < Margin) then        Result := windows.HTTOPLEFT      else if (Top < Margin) and (Right < Margin) then        Result := windows.HTTOPRIGHT      else if (Bottom < Margin) and (Left < Margin) then        Result := windows.HTBOTTOMLEFT      else if (Bottom < Margin) and (Right < Margin) then        Result := windows.HTBOTTOMRIGHT      else if (Top < Margin) then        Result := windows.HTTOP      else if (Left < Margin) then        Result := windows.HTLEFT      else if (Bottom < Margin) then        Result := windows.HTBOTTOM      else if (Right < Margin) then        Result := windows.HTRIGHT;    end;    Exit;  end;  Result := CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);end; ---------------------------------------------------------------------- jamie · 2025-11-22 00:18 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, Lmessages, LclIntf; type   { TForm1 }   TForm1 = class(TForm)  private   public    procedure Hittest(var Msg: TLMNCHITTEST); message LM_NCHITTEST;  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Hittest(var Msg: TLMNCHITTEST);const  Margin = 50;  HTTOP = 12;  HTTOPLEFT = 13;  HTLEFT = 10;  HTTOPRight = 14;  HTBottomLeft = 16;  HTBottomRight = 17;  HTbottom = 15;  HTRight = 11;var  R: TRect;begin  inherited;  R := BoundsRect;  if Abs(Msg.YPos - R.Top) < Margin then  begin    if Abs(Msg.XPos - R.Left) < Margin then      Msg.Result := HTTOPLEFT    else    if Abs(Msg.XPos - R.Right) < Margin then      Msg.Result := HTTOPRIGHT    else      Msg.Result := HTTOP;  Exit;  end;  if Abs(Msg.YPos - R.Bottom) < Margin then  begin    if Abs(Msg.XPos - R.Left) < Margin then      Msg.Result := HTBottomLEFT  else    if Abs(Msg.XPos - R.Right) < Margin then      Msg.Result := HTBottomRIGHT    else      Msg.Result := HTBottom;    Exit;  end;  if Abs(Msg.XPos - R.Left) < Margin then    Msg.Result := HTLeft;  if ABS(Msg.XPos - R.Right) < Margin then    MSg.Result := HTRight;end; end.  Jamie ---------------------------------------------------------------------- jamie · 2025-11-22 01:20 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 TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  MouseWentDownHere := TPoint.Create(X,Y);end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);Const Margin=10; Var   M,C:TRect;   DIf:TPoint;begin   If Not (ssLeft in Shift) then exit;// only do this if left button is down.   M:=ClientRect;   C:= M;   C.Inflate(-Margin,-Margin);//Shrink a rect.   If Not C.Contains(TPoint.Create(X,Y)) Then //size from sides.   Begin   Dif := TPoint.Create(MouseWentDownHere.X-X,MouseWentDownHere.Y-Y);     If Y < C.Top Then  {Top Side}     Begin      Top := Top-Dif.Y;      Height := Height+Dif.Y;     end;     {Complete the other remaining sides.}   end else   Begin  //Drag from center rect;    Dif := TPoint.Create(MouseWentDownHere.X-X,MouseWentDownHere.Y-Y);   Top:=Top-Dif.Y;   Left := Left-Dif.X;  End;end;                                       For a Borderless form. I only completed the TOP side size. Grab within the margin on top and you should be able to size the height. anywhere else, you can move it.  simply complete the other 3 sides I didn't do. Jamie ---------------------------------------------------------------------- Pe3s · 2025-11-22 09:33 if I set BorderStyle := bsNone in the object inspector and add the code 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  inherited CreateParams(Params);   Params.Style := Params.Style and    not (WS_CAPTION or WS_THICKFRAME or WS_BORDER);  this scaling does not work, handles are missing I tested this code earlier and I believe it causes the form to freeze during scaling. 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 TForm1.CreateParams(var Params: TCreateParams);begin  inherited CreateParams(Params);  Form1.BorderStyle:= bsNone;end; ---------------------------------------------------------------------- Zoran · 2025-11-22 09:48 Setting Form.BorderStyle might trigger recreating the window. I don't know what Form.CreateParams do (I'm not too experienced in this kind of programming), but if this is some procedure which is called inside process of creating the window, then you shouldn't set border style there, as it will lead to calling the same procedure (and recreating the window) endlessly. ---------------------------------------------------------------------- n7800 · 2025-11-22 18:30 Yes, changing the "BorderStyle" property recreates the window (definitely on Windows). I've already had unexpected problems because of this, where registered hotkeys stopped working. ---------------------------------------------------------------------- Pe3s · 2025-11-24 09:19 Is there a way to bypass and correct this? ---------------------------------------------------------------------- Pe3s · 2025-11-25 12:06 What do I need to add to add scaling handles if I set BorderStyle:= bsNone in the object inspector? 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 TForm1.WMNCHitTest(var Msg: TWMNCHitTest);const  EDGEDETECT = 7;var  deltaRect: TRect;begin  inherited;  if BorderStyle = bsNone then    with Msg, deltaRect do    begin      Left   := XPos - BoundsRect.Left;      Right  := BoundsRect.Right - XPos;      Top    := YPos - BoundsRect.Top;      Bottom := BoundsRect.Bottom - YPos;    if (Top < EDGEDETECT) and (Left < EDGEDETECT) then        Result := HTTOPLEFT      else if (Top < EDGEDETECT) and (Right < EDGEDETECT) then        Result := HTTOPRIGHT      else if (Bottom < EDGEDETECT) and (Left < EDGEDETECT) then        Result := HTBOTTOMLEFT      else if (Bottom < EDGEDETECT) and (Right < EDGEDETECT) then        Result := HTBOTTOMRIGHT      else if (Top < EDGEDETECT) then        Result := HTTOP      else if (Left < EDGEDETECT) then        Result := HTLEFT    else if (Bottom < EDGEDETECT) then        Result := HTBOTTOM      else if (Right < EDGEDETECT) then        Result := HTRIGHT        end;end;