Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I would like to prevent the user from being able to drag my form window. I set the FormBorderStyle of the property of the form to 'none' but this removes the caption bar which I don't want.

 

Can anyone help me?.

 

Thanks

Posted (edited)

I like simple. I would just use this in the Form's Move event :

 

Me.Top = 100
Me.Left = 100
Messagebox.show("Try that again, and I'll break your legs!")

 

 

...but since you want to be all difficult about it, I found this somewhere:

 

Some a this up top:

Imports System.Runtime.InteropServices

 

And a lil this in the class:

   <StructLayoutAttribute(LayoutKind.Sequential)> _
   Structure WM_MOVINGRECT
       Dim Left, Top, Right, Bottom As Integer
   End Structure

   Public Const WM_MOVING As Integer = &H216

   Protected Overrides Sub WndProc(ByRef m As Message)
       If m.Msg = WM_MOVING Then

           Dim lParam As WM_MOVINGRECT = CType(m.GetLParam(GetType(WM_MOVINGRECT)), WM_MOVINGRECT)

           lParam.Left = Me.Left
           lParam.Top = Me.Top
           lParam.Right = Me.Right
           lParam.Bottom = Me.Bottom
           Marshal.StructureToPtr(lParam, m.LParam, True)
       End If
       MyBase.WndProc(m)
   End Sub


Edited by JumpsInLava

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...