Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None后鼠标可以拖动窗体改变其大小。http://topic.csdn.net/u/20080327/15/bef23a98-8c38-4eb6-b953-4fa150690124.html
这里面有解决办法。功能已经实现了:在窗体上放置一个比窗体小一圈的层,小出的部分画上背景色。现在要求把上方的“边框”去掉,这样一来鼠标经过窗体上方的时候,就不出现向上拉伸窗体变大的鼠标提示了(当然也无法向上拉伸变大窗体了)我觉得,应该是层把窗体上方覆盖的原因造成的。如何解决这个问题呢?我尝试过下列方法:当鼠标位置在panel的0-2的时候向窗体发出消息(SendMessage是一个API函数),跟踪发现消息是发送了 
 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) 也接到了,但还是没有实现功能。相关方法如下:  '绘制的背景边框,top border =0 后就出现上述问题了。
  Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
    MyBase.OnPaintBackground(e)
ControlPaint.DrawBorder(g, Me.ClientRectangle, _
            BorderColor, 3, ButtonBorderStyle.Solid, _
            BorderColor, 0, ButtonBorderStyle.Solid, _
            BorderColor, 3, ButtonBorderStyle.Solid, _
            BorderColor, 3, ButtonBorderStyle.Solid)
  End Sub
'引入API
Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal lParam As Integer, ByVal wParam As Integer) As IntPtr  Private Sub Panel1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
    MouseAbsolutePosion = e.Location()
    If (Windows.Forms.MouseButtons.Left) Then
      If MouseAbsolutePosion.Y >= 0 And MouseAbsolutePosion.Y <= 2 Then
        SendMessage(Me.Handle, WM_NCHITTEST, HTTOP, 0) '向window发送消息
      End If
    End If
  End Sub  ’覆写WndProc方法
  Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    MyBase.WndProc(m)
    If (m.Msg = CONST_BP_WM_NCHITTEST) Then
      'If mObjChildFormStyle <> Windows.Forms.FormBorderStyle.None Then
      Dim lPoint As New Point((CInt(m.LParam) And &HFFFF), ((CInt(m.LParam) >> &H10) And &HFFFF))
      lPoint = MyBase.PointToClient(lPoint)      If (lPoint.X <= CONST_BP_AREA) Then
        If (lPoint.Y <= CONST_BP_AREA) Then
          m.Result = New IntPtr(CONST_BP_HTTOPLEFT)
        ElseIf (lPoint.Y >= (MyBase.ClientSize.Height - CONST_BP_AREA)) Then
          m.Result = New IntPtr(CONST_BP_HTBOTTOMLEFT)
        Else
          m.Result = New IntPtr(CONST_BP_HTLEFT)
        End If
      ElseIf (lPoint.X >= (MyBase.ClientSize.Width - CONST_BP_AREA)) Then
        If (lPoint.Y <= CONST_BP_AREA) Then
          m.Result = New IntPtr(CONST_BP_HTTOPRIGHT)
        ElseIf (lPoint.Y >= (MyBase.ClientSize.Height - CONST_BP_AREA)) Then
          m.Result = New IntPtr(CONST_BP_HTBOTTOMRIGHT)
        Else
          m.Result = New IntPtr(CONST_BP_HTRIGHT)
        End If
      ElseIf (lPoint.Y <= CONST_BP_AREA) Then
        m.Result = New IntPtr(CONST_BP_HTTOP)      ElseIf (lPoint.Y >= (MyBase.ClientSize.Height - CONST_BP_AREA)) Then
        m.Result = New IntPtr(CONST_BP_HTBOTTOM)      Else
   
      End If
  End Sub再次表示感谢

解决方案 »

  1.   

    http://blog.csdn.net/adandelion/archive/2008/09/09/2902632.aspx这里是代码
      

  2.   

    把form的边界设为None,然后把代码粘贴上:protected override CreateParams CreateParams
            {
                get
                {
                    CreateParams cp = base.CreateParams;
                    cp.Style |= 0xC0000 + 0x20000;
                    return cp;
                }
            }        [DllImport("user32.dll")]
            public static extern bool ReleaseCapture();        public const int HWND_BROADCAST = 0xFFFF;
            public const int WM_FONTCHANGE = 0x1D;
            [DllImport("user32.dll")]
            public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
            public static int WM_SYSCOMMAND = 0x0112;
            public static int SC_MOVE = 0xF010;
            public static int HTCAPTION = 0x0002;
     
            private void Form9_MouseDown(object sender, MouseEventArgs e)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);        }
    把Form9改成你自己的form
      

  3.   

    GentleCat 的方法,无能满足要求,窗体不是none的,周围还是有系统边框的。