虽然可以通过重载CreateParams实现上述目的,但是有一个非常讨厌的粗边框,如何才能去掉?

解决方案 »

  1.   

    procedure TForm1.CreateParams(var Params:TCreateParams);
    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设为空也没有用。
     
      

  2.   

    谢谢 rouqing(*冰雨&双子座奇缘*) , 但是边框还是比较粗,我可以实现细边框,但是却不能改变大小,或者是可以改变大小却不是细边框。