You'll have to create a new class which inherits from form, then make all
your forms inherit from this new form. Here is the class:
<WatchForWrapping>
Public Class MovableForm
Inherits System.Windows.Forms.Form
Private m_blnMovable As Boolean
Private Const WM_NCLBUTTONDOWN As Integer = &HA1
Private Const WM_SYSCOMMAND As Integer = &H112
Private Const HTCAPTION As Integer = &H2
Private Const SC_MOVE As Integer = &HF010
Public Sub New()
MyBase.New()
m_Movable = True
End Sub
<System.ComponentModel.Category("Behavior"),
System.ComponentModel.Description("Allows the form to be moved")> _
Public Property Movable() As Boolean
Get
Return m_blnMovable
End Get
Set(ByVal Value As Boolean)
m_blnMovable = Value
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
If Not m_blnMovable Then
If m.Msg = WM_SYSCOMMAND And m.WParam.ToInt32 = SC_MOVE Then
Return
If m.Msg = WM_NCLBUTTONDOWN And m.WParam.ToInt32 = HTCAPTION
Then Return
End If
MyBase.WndProc(m)
End Sub
End Class
</WatchForWrapping>
This adds a Movable property to your form. Set it to false and the form
cannot be moved. The property will appear in the property browser under the
'Behavior' section. Remember: The forms you would like to have this property
must inherit from MovableForm, and the project must be built after you
create this class before your forms can inherit from it. Go into the code
and change the Inherits line of your form. Just to be safe, build your
project then view the form in the Designer, and play with your Movable
property.
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit