我要在窗体的类型在bs_None状态下,实现其在bs_Sizeable下的功能,即鼠标在窗体右下角移动能改变窗体的大小,当窗体缩小时,自动出现滚动条,望大家帮帮忙,看看如何实现.多谢了.

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
      private
        { Private declarations }
        procedure WmNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);
    const v=3; //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
    else
        Msg.Result:=HTCAPTION;
    end;
    end.
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Forms,
      Dialogs, ExtCtrls, Controls;type
      TForm1 = class(TForm)
        Panel1: TPanel;
      private
        { Private declarations }
        procedure CreateParams(var Params: TCreateParams); override;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CreateParams(var Params: TCreateParams);
    begin
      inherited CreateParams(Params);
      Params.Style := Params.Style or WS_THICKFRAME;
    end;end.滚动不太好弄,最好加个SCrollBox,再把控件放里面.