我想做无边界的形式。我的问题是,当我想要调整表单大小(在左侧或顶部)时,另一侧的表单正在跳跃。(见附件 gif。)我尝试了 SetWindowPos 和 WndProc 但类似的问题。
问题:如何使用 ResizeRedraw 和 Doublebuffering 调整无边框表单的大小而不会出现故障?
这是我的简化代码:
Public Class Form1
Public Sub New()
DoubleBuffered = True
SetStyle(ControlStyles.ResizeRedraw, True)
FormBorderStyle = FormBorderStyle.None
End Sub
Dim down As Boolean = False
Dim _Right As Integer = 0
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
_Right = Right
down = True
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If down Then
Dim xy As Point = PointToScreen(e.Location)
SetBounds(xy.X - 2, Me.Top, _Right - xy.X - 2, Height)
End If
End Sub
End Class
操作系统:Windows 7
开发:VS 2015、VB、.NET 2.0