15 个解决方案
#1
没人会么?我只知道没有控件时的做法;
***************
怎样可以不要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.
#2
没人会么?
#3
up
#4
在你的Form上放一个TApplicationEvents控件,
在它的OnMessage事件中
如果是WM_MOUSEMOVE,
判断Curosor在Form的什么位置,设置相应的光标,
如呆是WM_LBUTTONDOWN,
判断Curosor在Form的什么位置,
SendMessage(Handle, WM_NCLBUTTONDOWN, ...),省略的为相应的HITTEST值.
在它的OnMessage事件中
如果是WM_MOUSEMOVE,
判断Curosor在Form的什么位置,设置相应的光标,
如呆是WM_LBUTTONDOWN,
判断Curosor在Form的什么位置,
SendMessage(Handle, WM_NCLBUTTONDOWN, ...),省略的为相应的HITTEST值.
#5
procedure WMNCHITTEST(var Message : TWMNCHITTEST) ; Message WM_NCHITTEST;
procedure TShowLog_FM.WMNCHITTEST;
begin
inherited;
if Message.Result = HTCLIENT then
Message.Result := HTCAPTION;
end;
procedure TShowLog_FM.WMNCHITTEST;
begin
inherited;
if Message.Result = HTCLIENT then
Message.Result := HTCAPTION;
end;
#6
能不能具体点,我不会改
#7
哟那样以下的代码,先让窗口在开启时具有可推动的边框
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事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
#8
用以下的代码,先让窗口在开启时具有可推动的边框
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事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
#9
用以下的代码,先让窗口在开启时具有可推动的边框
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事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
#10
你只要将你的
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;
就可以了吧!
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;
就可以了吧!
#11
如果不可以告诉我
#12
不好用,我在上面放了一个 TFlatTabControl 然后用 SetWindowRgn 切割窗体,窗体并不能接受 MouseMove 事件,......
#13
Vestige,把你的E-MAIL给我,我做个例了MAIL给你好了(XZYLZH.163.NET)
#14
关注!学习!
#15
我好长一段时间没上网了,我的E_Mail是 vestige@china.com
#1
没人会么?我只知道没有控件时的做法;
***************
怎样可以不要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.
#2
没人会么?
#3
up
#4
在你的Form上放一个TApplicationEvents控件,
在它的OnMessage事件中
如果是WM_MOUSEMOVE,
判断Curosor在Form的什么位置,设置相应的光标,
如呆是WM_LBUTTONDOWN,
判断Curosor在Form的什么位置,
SendMessage(Handle, WM_NCLBUTTONDOWN, ...),省略的为相应的HITTEST值.
在它的OnMessage事件中
如果是WM_MOUSEMOVE,
判断Curosor在Form的什么位置,设置相应的光标,
如呆是WM_LBUTTONDOWN,
判断Curosor在Form的什么位置,
SendMessage(Handle, WM_NCLBUTTONDOWN, ...),省略的为相应的HITTEST值.
#5
procedure WMNCHITTEST(var Message : TWMNCHITTEST) ; Message WM_NCHITTEST;
procedure TShowLog_FM.WMNCHITTEST;
begin
inherited;
if Message.Result = HTCLIENT then
Message.Result := HTCAPTION;
end;
procedure TShowLog_FM.WMNCHITTEST;
begin
inherited;
if Message.Result = HTCLIENT then
Message.Result := HTCAPTION;
end;
#6
能不能具体点,我不会改
#7
哟那样以下的代码,先让窗口在开启时具有可推动的边框
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事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
#8
用以下的代码,先让窗口在开启时具有可推动的边框
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事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
#9
用以下的代码,先让窗口在开启时具有可推动的边框
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事件中自己写代码,比如可不可以该窗口的大小,和改到多少大小等等,
我做了一个程序实现了这个功能,但是太大了,我发给你吧
#10
你只要将你的
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;
就可以了吧!
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;
就可以了吧!
#11
如果不可以告诉我
#12
不好用,我在上面放了一个 TFlatTabControl 然后用 SetWindowRgn 切割窗体,窗体并不能接受 MouseMove 事件,......
#13
Vestige,把你的E-MAIL给我,我做个例了MAIL给你好了(XZYLZH.163.NET)
#14
关注!学习!
#15
我好长一段时间没上网了,我的E_Mail是 vestige@china.com