如何创建一个可以改变大小的无标题栏的窗体? 虽然可以通过重载CreateParams实现上述目的,但是有一个非常讨厌的粗边框,如何才能去掉? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TForm1.CreateParams(var Params:TCreateParams);begininherited CreateParams(Params);Params.Style := WS_SIZEBOX orWS_POPUP orWS_BORDER;end;*******************procedure TForm1.FormCreate(Sender: TObject);beginborderstyle:=bsSizeable;setwindowlong(handle,gwl_style,getwindowlong(handle,gwl_style) and not ws_caption);clientheight:=height;end;************************TForm1=class(TForm)...publicprocedure CreateParams(var Params: TCreateParams); override;// 加入这一行end;// Copy 如下代码即可procedure TForm1.CreateParams(var Params: TCreateParams);begininherited CreateParams(Params);with Params dobeginStyle := (Style or WS_POPUP) xor (ws_dlgframe);///如果要凹下去的效果,则加入下面这行,否则去掉ExStyle := ws_ex_clientedge;end;end;***************怎样可以不要Form的标题栏和边界但可以保留改变Form的大小的功能:usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls;typeTForm1 = class(TForm)privateprocedure WmNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST;{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);const v=10; //border widthvar p:TPoint;beginp:=Point(Msg.XPos,Msg.YPos);p:=ScreenToClient(p);if PtInRect(Rect(0,0,v,v),p) thenMsg.Result:=HTTOPLEFTelse if PtInRect(Rect(Width-v,Height-v,Width,Height),p) thenMsg.Result:=HTBOTTOMRIGHTelse if PtInRect(Rect(Width-v,0,Width,v),p) thenMsg.Result:=HTTOPRIGHTelse if PtInRect(Rect(0,Height-v,v,Height),p) thenMsg.Result:=HTBOTTOMLEFTelse if PtInRect(Rect(v,0,Width-v,v),p) thenMsg.Result:=HTTOPelse if PtInRect(Rect(0,v,v,Height-v),p) thenMsg.Result:=HTLEFTelse if PtInRect(Rect(Width-v,v,Width,Height-v),p) thenMsg.Result:=HTRIGHTelse if PtInRect(Rect(v,Height-v,Width-v,Height),p) thenMsg.Result:=HTBOTTOM;Inherited;end;end.*************************类似网络蚂蚁的悬浮窗体源码:protected:virtual void __fastcall CreateParams(TCreateParams & Param);void __fastcall TForm2::CreateParams(TCreateParams & Param){//调用基类TForm::CreateParams(Param);//去掉窗口标题区Param.Style=Param.Style & ~WS_CAPTION;Param.Style=Param.Style | WS_POPUP;//设为总在最上面Param.ExStyle=Param.ExStyle | WS_EX_TOPMOST;//设Windows Owner为Desktop WindowParam.WndParent=GetDesktopWindow();}注意:1、Windows Owner与Windows Parent不同,用::SetParent函数和设置Form?->Parent这能设置Windows Parent,不能设置Windows Owner,要实现FlashGet的悬浮窗必须要设置Windows Owner。2、Form的BorderStyle要设为bsToolWindow,不然在任务栏上会显示出这个窗口的标题,将Caption设为空也没有用。 谢谢 rouqing(*冰雨&双子座奇缘*) , 但是边框还是比较粗,我可以实现细边框,但是却不能改变大小,或者是可以改变大小却不是细边框。 有一个线程的问题,请教 intraweb下打印用什么控件? SQL语句的调用问题 怎样通过delphi程序给win2000 or xp添加用户? 用ado连接oracle不上,服务器已经填写了,帐号密码sysman/oem_temp,system/manager都尝试过了 关于SQL 万分紧急!!! 请问怎样限制一个FORM只在一个创建它的FORM中固定的区域内可移动? 怎样设置dbcombobox才能使他显示数据库里的那个字段, 急求一个Delphi的高手帮我解决一个调用的问题 关于MIDAS应用程序服务器的几个问题! 请教三层不让服务器弹出窗口的办法 MIS远程数据库连接
begin
inherited CreateParams(Params);
Params.Style := WS_SIZEBOX or
WS_POPUP or
WS_BORDER;
end;
*******************
procedure TForm1.FormCreate(Sender: TObject);
beginborderstyle:=bsSizeable;setwindowlong(handle,gwl_style,getwindowlong(handle,gwl_style) and not ws_caption);clientheight:=height;end;************************TForm1=class(TForm)...publicprocedure CreateParams(var Params: TCreateParams); override;// 加入这一行end;// Copy 如下代码即可procedure TForm1.CreateParams(var Params: TCreateParams);begininherited CreateParams(Params);with Params dobeginStyle := (Style or WS_POPUP) xor (ws_dlgframe);///如果要凹下去的效果,则加入下面这行,否则去掉ExStyle := ws_ex_clientedge;end;end;***************怎样可以不要Form的标题栏和边界但可以保留改变Form的大小的功能:usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls;typeTForm1 = class(TForm)privateprocedure WmNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST;{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);const v=10; //border widthvar p:TPoint;beginp:=Point(Msg.XPos,Msg.YPos);p:=ScreenToClient(p);if PtInRect(Rect(0,0,v,v),p) thenMsg.Result:=HTTOPLEFTelse if PtInRect(Rect(Width-v,Height-v,Width,Height),p) thenMsg.Result:=HTBOTTOMRIGHTelse if PtInRect(Rect(Width-v,0,Width,v),p) thenMsg.Result:=HTTOPRIGHTelse if PtInRect(Rect(0,Height-v,v,Height),p) thenMsg.Result:=HTBOTTOMLEFTelse if PtInRect(Rect(v,0,Width-v,v),p) thenMsg.Result:=HTTOPelse if PtInRect(Rect(0,v,v,Height-v),p) thenMsg.Result:=HTLEFTelse if PtInRect(Rect(Width-v,v,Width,Height-v),p) thenMsg.Result:=HTRIGHTelse if PtInRect(Rect(v,Height-v,Width-v,Height),p) thenMsg.Result:=HTBOTTOM;Inherited;end;end.*************************类似网络蚂蚁的悬浮窗体源码:protected:virtual void __fastcall CreateParams(TCreateParams & Param);void __fastcall TForm2::CreateParams(TCreateParams & Param){//调用基类TForm::CreateParams(Param);//去掉窗口标题区Param.Style=Param.Style & ~WS_CAPTION;Param.Style=Param.Style | WS_POPUP;//设为总在最上面Param.ExStyle=Param.ExStyle | WS_EX_TOPMOST;//设Windows Owner为Desktop WindowParam.WndParent=GetDesktopWindow();}注意:1、Windows Owner与Windows Parent不同,用::SetParent函数和设置Form?->Parent这能设置Windows Parent,不能设置Windows Owner,要实现FlashGet的悬浮窗必须要设置Windows Owner。2、Form的BorderStyle要设为bsToolWindow,不然在任务栏上会显示出这个窗口的标题,将Caption设为空也没有用。