送分题(100分)

  • 主题发起人 主题发起人 ypy
  • 开始时间 开始时间
Y

ypy

Unregistered / Unconfirmed
GUEST, unregistred user!
一个FORM不要标题栏(上面蓝色的条)但又可以改变大小,怎么实现?
将FORM的BorderStyle设为bsNone可以去掉标题栏,但也不能改变大小了:(
 
看样子只有自己写程序,判断鼠标是否在表单边缘,如果是则改变鼠标指针为双向箭头,再监测鼠标
移动情况并改变表单大小即可。
或者1、BorderStyle为bsSizeable
2、
public
{ Public declarations }
procedure CreateParams(var Params: TCreateParams); override;

procedure TNeoForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
Style :=Style and (not WS_CAPTION);
Style :=Style or WS_POPUP
end
end;
 
同意楼上的意见
或者拦截窗口消息进行处理
 
谢谢bswilson,能把你TNeoForm发一份给我吗?我也想做个
 
bsnone
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
private
procedure WmNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);
const v=10; //border width
var p:TPoint;
begin
Inherited;
p:=Point(Msg.XPos,Msg.YPos);
p:=ScreenToClient(p);
if PtInRect(Rect(0,0,v,v),p) then
Msg.Result:=HTTOPLEFT
else if PtInRect(Rect(Width-v,Height-v,Width,Height),p) then
Msg.Result:=HTBOTTOMRIGHT
else if PtInRect(Rect(Width-v,0,Width,v),p) then
Msg.Result:=HTTOPRIGHT
else if PtInRect(Rect(0,Height-v,v,Height),p) then
Msg.Result:=HTBOTTOMLEFT
else if PtInRect(Rect(v,0,Width-v,v),p) then
Msg.Result:=HTTOP

else if PtInRect(Rect(0,v,v,Height-v),p) then
Msg.Result:=HTLEFT
else if PtInRect(Rect(Width-v,v,Width,Height-v),p) then
Msg.Result:=HTRIGHT
else if PtInRect(Rect(v,Height-v,Width-v,Height),p) then
Msg.Result:=HTBOTTOM;
end;
end.
 
///////////////BorderStyle 为 bsNone
同意楼上,完整代码如下:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure CreateParams(var params:TCreateParams);override;
{ Public declarations }
end;

var
Form1: TForm1;

implementation
procedure TForm1.CreateParams(var params:TCreateParams);
begin //方法的重置,用于重新绘制窗口
Inherited createparams(params) ; //可以托动窗体的边框(此时窗体是无边框的)
params.style:=WS_THICKFRAME or WS_POPUP or WS_BORDER;
end;
{$R *.dfm}

end.
 
多人接受答案了。
 
后退
顶部