Is there a way to make a form unmoveable in .NET?
:)
Printable View
Is there a way to make a form unmoveable in .NET?
:)
You can do it this way but there probably is a better way.Code:Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
Form1.ActiveForm.Width = 200
Form1.ActiveForm.Height = 200
End Sub
I was hoping for a more unflickery way (provided you really meant to use OnMove, otherwise I have no idea where you are going). I could set the borderstyle to None, but I would rather not. Thanks anyway.
:)
umm can you do it in vb6? maybe someone could help you convert the APIs to .NETQuote:
Originally posted by crptcblade
I was hoping for a more unflickery way (provided you really meant to use OnMove, otherwise I have no idea where you are going). I could set the borderstyle to None, but I would rather not. Thanks anyway.
:)
VB6 is easy. Moveable = False at design time ;).Quote:
Originally posted by MrPolite
umm can you do it in vb6? maybe someone could help you convert the APIs to .NET
The only other way I know to do it is to remove the Move option from the system menu of the form. Anybody want to point in the right direction?
I'd rather work the actual code out for myself, seeing as how I'm trying to get used to all this .NET malarky. Just a nice push will do.
:)
well , you have either use this flickry code or to to make your
form's border style to none and create your own titlebar.
VB Code:
Dim LastLocation As Point Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As _ System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then LastLocation = Me.Location End If End Sub Private Sub Form1_Move(ByVal sender As Object, ByVal e As _ System.EventArgs) Handles MyBase.Move Me.Location = LastLocation End Sub
Well, that sucks. But if I must, then I must.
:)
I know it's silly:D but If you could overcome that flickring , it would be great .
Well, I hacked it a bit. I overrode the WndProc method of the form and checked for a left mouse down message on the titlebar. If I get it, then I cancel the message.
:)
can you post your code anyways ?:)Quote:
Originally posted by crptcblade
Well, I hacked it a bit. I overrode the WndProc method of the form and checked for a left mouse down message on the titlebar. If I get it, then I cancel the message.
:)
Sure...
It could probably stand to be cleaned up a little, but it works.Code:Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim i As IntPtr = New IntPtr(0)
Dim cap As IntPtr = New IntPtr(HTCAPTION)
If (m.Msg.Equals(WM_NCLBUTTONDOWN)) And (m.WParam.Equals(cap)) Then
m.Result = i
Exit Sub
End If
MyBase.WndProc(m)
End Sub
:)