Full skin / Resizable bsNone lazarus / 31-LCL ---------------------------------------------------------------------- fatmonk · 2016-08-27 19:54 Is it possible to create a form with no border bsNone that is still resizable? I'm trying to create a form that is fully skinned - ie no border and my own title bar and close button. My plan was to use BGRA Controls buttons with rounding and a transparent form to create something that looks good, but I've stumbled at the first step - as soon as I set bsNone the form cannot be resized - so is there another way to achieve the same thing, maybe by manipulating the form's border style directly rather than using the built in styles? -FM ---------------------------------------------------------------------- lainz · 2016-08-27 20:08 See the demo bgracontrols\test\BGRA Ribbon Custom, it does what you want. ---------------------------------------------------------------------- fatmonk · 2016-08-27 20:31 I can't get to my dev machine right now to look at that demo, but from the description of the ribbon suggests that this might just do the title bar bit. Is that right? Or does the ribbon demo also show me how I can have a none-square form that is resizable? (my plan was to use a rounded BGRA button or a shape anchored to the transparent form's edges as the background to the whole application) Thanks, FM ---------------------------------------------------------------------- lainz · 2016-08-27 20:40 It does the skin and the resize you need, but not the shape, it's square. ---------------------------------------------------------------------- fatmonk · 2016-08-28 17:25 Thanks lainz, Nice demo, but I'm afraid it's not what I'm looking for. The demo only allows resizing by dragging the image - I need to be able to resize by dragging any of the sides or corners of the form, as with a fsSizeable, even though there are no normal form edges. I'll post a mock up of what I'm trying to do in a while... -FM ---------------------------------------------------------------------- fatmonk · 2016-08-28 18:24 OK, it's a bit hacky (and I need to tweak the functions to make it a bit more logical in terms of what dragging each edge does), but taking ideas from BGRA Ribbon Custom example I've come up with the attcahed. It uses BGRA Buttons and Shapes and some code I found on the web to make forms transparent by a particular colour (see here)... It kind of works, and with a bit more work should give me a full skinned application, I think. (Note that the title bar doesn't quite work as I wanted, so I will probably switch to just using more shapes to create the title and application icon.) -FM ---------------------------------------------------------------------- lainz · 2016-08-28 19:35 Quote from: fatmonk on August 28, 2016, 07:25:16 pmThanks lainz, Nice demo, but I'm afraid it's not what I'm looking for. The demo only allows resizing by dragging the image - I need to be able to resize by dragging any of the sides or corners of the form, as with a fsSizeable, even though there are no normal form edges. I'll post a mock up of what I'm trying to do in a while... -FM It has an unit to resize from all sides, it's by default commented. ---------------------------------------------------------------------- balazsszekely · 2016-08-29 11:23 See attachment. 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, LCLType; var  PrevWndProc: WNDPROC; 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; procedure TForm1.FormCreate(Sender: TObject);begin  PrevWndProc := Windows.WNDPROC(SetWindowLongPtr(Self.Handle, GWL_WNDPROC, PtrInt(@WndCallback)));end; procedure TForm1.CreateParams(var Params: TCreateParams);begin  inherited CreateParams(Params);  Self.BorderStyle := bsNone;end ---------------------------------------------------------------------- fatmonk · 2016-08-29 13:39 @GetMem I wish I had the first clue what that code was doing !  Will have a play with that to see if I can figure out out. -FM ---------------------------------------------------------------------- balazsszekely · 2016-08-30 10:03 @fatmonk You can also add the ability to move the form(BorderStyle --> bsNone), like you would move a form with caption(title) bar. Just add two lines to the function WndCallback: 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;  Caption = 15; //add thisvar  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 (Top > Margin) and (Top < Caption) then //add this line        Result := windows.HTCAPTION      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; ---------------------------------------------------------------------- fatmonk · 2016-08-30 14:59 @lainz Where is that FormMouseMove procedure supposed to be called from? I've tried is in the Form's onMouseMove event, but that's not working.... -FM ---------------------------------------------------------------------- lainz · 2016-08-30 16:14 Quote from: fatmonk on August 30, 2016, 04:59:12 pm@lainz Where is that FormMouseMove procedure supposed to be called from? I've tried is in the Form's onMouseMove event, but that's not working.... -FM I don't really know, I'm not the author of that demo: http://forum.lazarus- ide.org/index.php/topic,24176.msg208207.html#msg208207 BTW About licence if you read it, there are no issues, that unit can be used. ---------------------------------------------------------------------- coasting · 2016-08-30 20:09 Quote from: fatmonk on August 30, 2016, 04:59:12 pm@lainz Where is that FormMouseMove procedure supposed to be called from? I've tried is in the Form's onMouseMove event, but that's not working.... -FM After my last text just got deleted by my browser, I keep my 2nd try a bit shorter now... Please look here: https://stackoverflow.com/questions/6652655/smooth-resizing-in-a- borderless-form-window-in-delphi Last post on bottom of the page contains all you need to get uResize running. The idea of using a non-visible form is just brilliant! Reason that's not working in BGRA Ribbon example is the design of my form. It just doesn't allow frmMain to see the mouse movements. The event frmMain.OnMouseMove isn't triggered as other controls are painted on top of frmMain. As I didn't find a way to pass through the mouse movements, I decided to resize the form by means of the imgResize image on bottom right of the form. That was quicker to implement. I have a basic window which does all this, i.e. borderless form, resizeable from all edges plus dropshadow ...but I strongly recommend to use uResize instead. coasting ---------------------------------------------------------------------- fatmonk · 2016-09-01 16:04 Still struggling I'm afraid... I've tried adding the SetMouseDown event to the OnMouseDown event for my invisible shapes I have around the edges of my form but when that procedure is called I get an External SIGSEGV from the line: 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   anchor_g.Left   := AForm.Left; right at the start of that procedure. I'm obviously doing something very wrong. - I've added uResize to the first uses clause in my main form's unit. - I've added invisible shapes to the top, left, right and bottom of my main form. - I've added the same OnMouseDown event to each of those invisible shapes. I'm guessing I'm missing something here... -FM ---------------------------------------------------------------------- coasting · 2016-09-01 20:21 I copied some lines from an old project. Maybe its of help... Should I have some spare time over the weekend I can try to do a small demo... 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  type   TBorderPos = (bpTopLeft, bpTopRight, bpBottomLeft,                bpBottomRight, bpTop, bpBottom,bpLeft,bpRight,bpnone);   vsForm: TBGRAVirtualScreen; ..implementation uses  uResize;.. procedure TForm1.FormCreate(Sender: TObject);begin  BorderStyle := bsNone;  {$ifdef Windows}  //  DropShadow(Handle); // Better to use SetClasslong() as follows (Windows OS only):  {Handle = all Forms, frmMain.Handle = only frmMain Form  SetClassLong(Handle, GCL_STYLE, GetClassLong(Handle, GCL_STYLE) or CS_DROPSHADOW);  }  SetClassLong(Form1.Handle, GCL_STYLE, GetClassLong(Form1.Handle, GCL_STYLE) or CS_DROPSHADOW);    SetWindowPos(Handle, HWND_TOP, Left, Top, Width, Height, SWP_FRAMECHANGED);  {$else}  // Something to be done for OS <> Windows?  {$endif}  DoubleBuffered := True;end; ..procedure TForm1.vsFormMouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  MouseCapture := True;end;      procedure TForm1.vsFormMouseMove(Sender: TObject;  Shift: TShiftState; X, Y: Integer); var LeftEdge,RightEdge,TopEdge,BottomEdge: Boolean;      BorderPosition: TBorderPos;      BW: Integer;   begin    BW := 8;    LeftEdge := False;    RightEdge := False;    TopEdge := False;    BottomEdge := False;    //Check if mouse cursor is on left or right edge    if X < BW then    begin      LeftEdge := True;    end    else if X > vsForm.Width-BW then    begin      RightEdge := True;    end;     //Check if mouse cursor is on top or bottom edge    if Y < BW then    begin      TopEdge := True;    end    else if Y > vsForm.Height-BW then    begin      BottomEdge := True;    end;     //Get border position by using if..else if..else clause in order for if block    //to break as soon as one of the conditions is met    //First check for corners    if TopEdge and LeftEdge then BorderPosition := bpTopLeft    else if TopEdge and RightEdge then BorderPosition := bpTopRight    else if BottomEdge and LeftEdge then BorderPosition := bpBottomLeft    else if BottomEdge and RightEdge then BorderPosition := bpBottomRight    //and only then check for individual edges    else if TopEdge then BorderPosition := bpTop    else if BottomEdge then BorderPosition := bpBottom    else if LeftEdge then BorderPosition := bpLeft    else if RightEdge then BorderPosition := bpRight    //mouse cursor is not on any border edge    else BorderPosition := bpNone;     //Finally you can use case statement to execute needed code based on which    //border edge is your mouse cursor positioned    case BorderPosition of      bpNone:      begin        Label1.Caption := 'Not on border';        vsForm.Cursor:=crDefault;      end;      bpLeft:      begin        Label1.Caption := 'Left border';        vsForm.Cursor:=crSizeWE;        if ssLeft in shift then          ResizeForm.SetMouseDown( self, 5 );      end;      bpRight:      begin        Label1.Caption := 'Right border';        vsForm.Cursor := crSizeWE;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 4 );      end;       bpTop:      begin        Label1.Caption := 'Top border';        vsBottom.Cursor := crSizeNS;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 10 );      end;      bpBottom:      begin        Label1.Caption := 'Bottom border';        vsForm.Cursor :=crSizeNS;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 8 );      end;      bpTopLeft:      begin        Label1.Caption := 'Top Left corner';        vsForm.Cursor :=crSizeNWSE;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 15 );      end;      bpTopRight:      begin        Label1.Caption := 'Top Right corner';        vsForm.Cursor :=crSizeNESW;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 14 );      end;      bpBottomLeft:    begin        Label1.Caption := 'Bottom Left corner';        vsForm.Cursor :=crSizeNESW;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 13 );      end;      bpBottomRight:    begin        Label1.Caption := 'Bottom Right corner';        vsForm.Cursor :=crSizeNWSE;        if ssLeft in Shift then          ResizeForm.SetMouseDown( self, 12 );      end;    end;  end; ---------------------------------------------------------------------- pixelink · 2016-09-01 23:54 I had a similar issue... no custom form shape though. I got what I was trying to do fixed... try this thread CREDIT TO GEMMEM http://forum.lazarus.freepascal.org/index.php/topic,33899.0.html ---------------------------------------------------------------------- mudah · 2020-05-22 06:10 Quote from: fatmonk on September 01, 2016, 06:04:35 pmStill struggling I'm afraid... I've tried adding the SetMouseDown event to the OnMouseDown event for my invisible shapes I have around the edges of my form but when that procedure is called I get an External SIGSEGV from the line: 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   anchor_g.Left   := AForm.Left; right at the start of that procedure. I'm obviously doing something very wrong. - I've added uResize to the first uses clause in my main form's unit. - I've added invisible shapes to the top, left, right and bottom of my main form. - I've added the same OnMouseDown event to each of those invisible shapes. I'm guessing I'm missing something here... -FM Copy uresize.pas and uresize.lfm into you project folder. Add uResize in the uses claus. Then add this line to your project *.lpr file 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 begin....Application.CreateForm(TResizeForm, ResizeForm); //<---- ThisApplication.Run;end.  The error will gone.