• Log in or sign up for an account here: https://www.sythe.org/login

Resize windows without borders in one method.

Flaming Idiots

Active Member
Joined
Dec 22, 2005
Sythe Gold
0
Messages
235
Age
36
Location
Alberta Canada
Resize windows without borders in one method.
How it works:

What it does is modify the result of the windows method WM_NCHITTEST.
So if it is within 3 pixels of the edge of the form, it will tell the form to allow resizing, and if it within 20 pixels of the top, it will let you drag the form.

How to use it:

Just add the following code into your form, and make sure your form has no border.
Code:
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.WndProc(m)
        If m.Msg = 132 And Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Then
            Dim z As Point = Control.MousePosition
            If Me.Parent IsNot Nothing Then z -= Me.Parent.PointToScreen(New Point())
            Static ResizePadding As New Padding(3)
            Dim Result As Integer = 0
            Select Case z.X
                Case Is < Left + ResizePadding.Left : Result = 10
                Case Is > Right - ResizePadding.Right : Result = 11
            End Select
            Select Case z.Y
                Case Is < Top + ResizePadding.Top
                    Select Case Result
                        Case 0 : Result = 12
                        Case 10 : Result = 13
                        Case 11 : Result = 14
                    End Select
                Case Is < Top + 20
                    Select Case Result
                        Case 0 : Result = 2
                    End Select
                Case Is > Bottom - ResizePadding.Bottom
                    Select Case Result
                        Case 0 : Result = 15
                        Case 10 : Result = 16
                        Case 11 : Result = 17
                    End Select
            End Select
            If Result <> 0 Then m.Result = Result
        End If
    End Sub
 
Runescape Gamblingrunescape gambling
Back
Top