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,
If yes, how ?
Thanks,
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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.
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(Sende r: 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
procedure TForm1.FormMouseDown(Sende
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