para el VB 2008
para redimenzionar con el boton derecho
Código
Friend Class MoverControles Inherits System.Windows.Forms.Form Private DX, DY As Integer Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, _ ByVal X As Integer, ByVal Y As Integer, ByVal cX As Integer, ByVal cY As Integer, ByVal wFlags As Integer) As Integer Const GWL_STYLE As Integer = (-16) Const WS_THICKFRAME As Integer = &H40000 Const SWP_DRAWFRAME As Integer = &H20 Const SWP_NOMOVE As Integer = &H2 Const SWP_NOSIZE As Integer = &H1 Const SWP_NOZORDER As Integer = &H4 Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load AsignarEventos(Me) End Sub Private Sub Control_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) DX = e.X DY = e.Y If e.Button = MouseButtons.Right Then CambiarEstilo(CType(sender, Control)) Else CType(sender, Control).BringToFront() End If End Sub Private Sub Control_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) If e.Button = MouseButtons.Left Then CType(sender, Control).Left = e.X + CType(sender, Control).Left - DX CType(sender, Control).Top = e.Y + CType(sender, Control).Top - DY End If End Sub Private Sub AsignarEventos(ByVal elControl As Control) Dim ctrl As Control For Each ctrl In elControl.Controls If ctrl.Name <> "cmdAlgo" And ctrl.Name <> "txtControl1" And ctrl.Name <> "txtControl1" Then ' aqui vaz agregando los controles que quieres estaticos y no redimensionables AddHandler ctrl.MouseDown, AddressOf Me.Control_MouseDown AddHandler ctrl.MouseMove, AddressOf Me.Control_MouseMove AsignarEventos(ctrl) End If Next End Sub Private Sub CambiarEstilo(ByVal aControl As Control) Dim Style As Integer Try Style = GetWindowLong(aControl.Handle.ToInt32, GWL_STYLE) If (Style And WS_THICKFRAME) = WS_THICKFRAME Then Style = Style Xor WS_THICKFRAME Else Style = Style Or WS_THICKFRAME End If SetWindowLong(aControl.Handle.ToInt32, GWL_STYLE, Style) SetWindowPos(aControl.Handle.ToInt32, Me.Handle.ToInt32, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME) Catch End Try End Sub End Class