没人会么?我只知道没有控件时的做法;
***************
怎样可以不要Form的标题栏和边界但可以保留改变Form的大小的功能:
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
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;
//Inherited;
end;end.
***************
怎样可以不要Form的标题栏和边界但可以保留改变Form的大小的功能:
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
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;
//Inherited;
end;end.
在它的OnMessage事件中
如果是WM_MOUSEMOVE,
判断Curosor在Form的什么位置,设置相应的光标,
如呆是WM_LBUTTONDOWN,
判断Curosor在Form的什么位置,
SendMessage(Handle, WM_NCLBUTTONDOWN, ...),省略的为相应的HITTEST值.
begin
inherited;
if Message.Result = HTCLIENT then
Message.Result := HTCAPTION;
end;
procedure CreateParams(var Params: TCreateParams); override;procedure TFormMain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
Style:=(Style or WS_POPUP) xor (ws_dlgframe);
ExStyle:=ws_ex_clientedge;
end;
end;然后在FormCanResize事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
procedure CreateParams(var Params: TCreateParams); override;procedure TFormMain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
Style:=(Style or WS_POPUP) xor (ws_dlgframe);
ExStyle:=ws_ex_clientedge;
end;
end;然后在FormCanResize事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
procedure CreateParams(var Params: TCreateParams); override;procedure TFormMain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
Style:=(Style or WS_POPUP) xor (ws_dlgframe);
ExStyle:=ws_ex_clientedge;
end;
end;然后在FormCanResize事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);
const v=10; //border width
var p:TPoint;
begin
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;
//Inherited;
end;
换成:procedure TForm1.WMNCHITTEST;
begin
inherited;
if Message.Result = HTCLIENT then
Message.Result := HTCAPTION;
end;就可以了吧!