Link to home
Create AccountLog in
Avatar of klompen
klompen

asked on

Borderless and resizeable Tform

Is it possible to make a borderless Tform but it still can be moved and resizeable?

If yes, how ?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of ZhaawZ
ZhaawZ
Flag of Latvia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Forgot to say - use SetWindowLong after the form is created (onCreate window or .dpr file (project --> view source))
About moving a form.. Well, there are several ways of doing it. Here`s a small example of what you need:



unit Unit1;

interface

uses
  Messages, Classes, Forms;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;
  end;

var
  Form1: TForm1;

implementation

uses Windows;

{$R *.DFM}

procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
inherited;
if M.Result = htClient then M.Result := htCaption;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(handle, gwl_style, ws_sizebox);
end;

end.
Another way of moving form (works also with controls - buttons, panels and others)

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
Perform(WM_SYSCOMMAND, SC_MOVE + 1, 0);
end;


This is good when you have some button or another control, which is used to move form. Then just write those 2 lines in control`s onMouseDown event