Custom Size Grip

sarthemaker

Active member
Joined
Sep 4, 2009
Messages
36
Programming Experience
5-10
My application's form has no border but I want it to have a size grip so I am trying to create my own. I have created this code to resize the form:

VB.NET:
    Private Sub SizeMouseup(ByVal sender As Object, ByVal e As MouseEventArgs) Handles SizeGrip.MouseUp
        FormDrag = False
    End Sub
    Private Sub SizeMousedown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles SizeGrip.MouseDown
        FormDragStart = e.Location
        FormDrag = True
        startHeight = Me.Width
        startWidth = Me.Height
    End Sub
    Private Sub SizeMousemove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles SizeGrip.MouseMove
        If FormDrag Then
            Me.ResizeRedraw = True
            Dim p1 = New Point(e.X, e.Y)
            Dim p2 = PointToScreen(p1)
            Dim pw = Math.Round(p2.X - FormDragStart.X)
            Dim ph = Math.Round(p2.Y - FormDragStart.Y)
me.size = new size(startWidth + pw, startHeight + ph)
        End If
    End Sub

The problem is that when its resizing the form starts flashing to random sizes. I also tested this with displaying the width and height as text in the form and the numbers were the right size.

Does anyone know how I can fix this or another way to resize a borderless form?
 
Back
Top