请问如何改变Border为:bsNone的窗体大小,就如bsSizeable的一样???
打错了,是BorderStyle 为:bsNone

解决方案 »

  1.   

    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm2 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
        procedure WMNCHITTEST(var Msg: TWMNCHITTEST); message WM_NCHITTEST;
      end;var
      Form2: TForm2;implementation{$R *.dfm}{ TForm2 }procedure TForm2.WMNCHITTEST(var Msg: TWMNCHITTEST);
    var
      vPoint: TPoint;
      vRect: TRect;
    begin
      inherited;
      GetWindowRect(Handle, vRect);
      vPoint.X := Msg.XPos;
      vPoint.Y := Msg.YPos;
      if PtInRect(Rect(vRect.Right - 5, vRect.Top + 5, vRect.Right + 5,
        vRect.Bottom - 5), vPoint) then
        Msg.Result := HTRIGHT
      else if PtInRect(Rect(vRect.Left - 5, vRect.Top + 5, vRect.Left + 5,
        vRect.Bottom - 5), vPoint) then
        Msg.Result := HTLEFT
      else if PtInRect(Rect(vRect.Left + 5, vRect.Top - 5, vRect.Right - 5,
        vRect.Top + 5), vPoint) then
        Msg.Result := HTTOP
      else if PtInRect(Rect(vRect.Left + 5, vRect.Bottom - 5, vRect.Right - 5,
        vRect.Bottom + 5), vPoint) then
        Msg.Result := HTBOTTOM
      else if PtinRect(Rect(vRect.Left - 5, vRect.Top - 5, vRect.Left + 5,
        vRect.Top + 5), vPoint) then
        Msg.Result := HTTOPLEFT
      else if PtInRect(Rect(vRect.Right - 5, vRect.Bottom - 5, vRect.Right + 5,
        vRect.Bottom + 5), vPoint) then
        Msg.Result := HTBOTTOMRIGHT
      else if PtInRect(Rect(vRect.Left - 5, vRect.Bottom - 5, vRect.Left + 5,
        vRect.Bottom + 5), vPoint) then
        Msg.Result := HTBOTTOMLEFT
      else if PtInRect(Rect(vRect.Right - 5, vRect.Top - 5, vRect.Right + 5,
        vRect.Left + 5), vPoint) then
        Msg.Result := HTTOPRIGHT;
    end;end.