1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Public Class Form1
Public Structure Rect
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Const WM_SIZING As Long = &H214
Const WMSZ_LEFT As Integer = 1
Const WMSZ_RIGHT As Integer = 2
Const WMSZ_TOP As Integer = 3
Const WMSZ_TOPLEFT As Integer = 4
Const WMSZ_TOPRIGHT As Integer = 5
Const WMSZ_BOTTOM As Integer = 6
Const WMSZ_BOTTOMLEFT As Integer = 7
Const WMSZ_BOTTOMRIGHT As Integer = 8
If m.Msg = WM_SIZING And m.HWnd.Equals(Me.Handle) Then
If m.WParam.ToInt32 = WMSZ_BOTTOM Or _
m.WParam.ToInt32 = WMSZ_RIGHT Or _
m.WParam.ToInt32 = WMSZ_BOTTOMRIGHT Then
' Set again the defined size
Dim r As Rect
r = DirectCast(System.Runtime.InteropServices.Marshal.PtrToStructure(m.LParam, GetType(Rect)), Rect)
r.right = Me.Right
r.bottom = Me.Bottom
System.Runtime.InteropServices.Marshal.StructureToPtr(r, m.LParam, True)
End If
End If
MyBase.WndProc(m)
End Sub
End Class |