I've finally solved the problem :)
The solution is to override the WndProc-Procedure and to check for the WM_NCHITTEST-Message there.
I've written a short sample:
Public Class Form1
Public Const WM_NCHITTEST As Integer = &H84
Dim _FixedState As FixedState = FixedState.Horizontal
Enum FixedState As Integer
None = 0
Horizontal = 1
Vertical = 2
Both = 3
End Enum
Enum HitTest As Integer
Caption = 2
Transparent = -1
Nowhere = 0
Client = 1
Left = 10
Right = 11
Top = 12
TopLeft = 13
TopRight = 14
Bottom = 15
BottomLeft = 16
BottomRight = 17
Border = 18
End Enum
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If m.Msg <> WM_NCHITTEST Or _FixedState = FixedState.None Then Return
If _FixedState = FixedState.Both Then
m.Result = New IntPtr(HitTest.Nowhere)
Else
Select Case m.Result.ToInt32
Case HitTest.Top, HitTest.Bottom
If _FixedState = FixedState.Vertical Then m.Result = New IntPtr(HitTest.Nowhere)
Case HitTest.Left, HitTest.Right
If _FixedState = FixedState.Horizontal Then m.Result = New IntPtr(HitTest.Nowhere)
Case HitTest.TopLeft
m.Result = New IntPtr(CInt(IIf(_FixedState = FixedState.Horizontal, HitTest.Top, HitTest.Left)))
Case HitTest.TopRight
m.Result = New IntPtr(CInt(IIf(_FixedState = FixedState.Horizontal, HitTest.Top, HitTest.Right)))
Case HitTest.BottomLeft
m.Result = New IntPtr(CInt(IIf(_FixedState = FixedState.Horizontal, HitTest.Bottom, HitTest.Left)))
Case HitTest.BottomRight
m.Result = New IntPtr(CInt(IIf(_FixedState = FixedState.Horizontal, HitTest.Bottom, HitTest.Right)))
End Select
End If
End Sub
End Class
The enumeration 'HitTest' can be looked up
here.
The variable _FixedState sets whether the width/height or both properties are fixed.
For me it works quite well :D
Regards, Kai