Creating a Movable Borderless Form
This wonderful code saved me from a lot of headaches. Great code!
//**************************************
//
// Name: Most professional way of moving
// a borderless form without APIs and witho
// ut mouse pointer coordinates
// Description:Want to move a form by cl
// ick and dragging on the client area beca
// use your form is bordless/captionless? T
// his IS the way to do it at low level pro
// gramming without the use of APIs... full
// y .NET-wise.
// By: Rodolfo Gonzalez Ruiz
//
// Assumes:Basically the code uses the W
// ndProc and changes the window message to
// make it believe that you are clicking on
// the form/window title bar.
//
// Side Effects:User must click on the f
// orm client area, if a control is placed
// on top, clicking on it will not drag the
// window.
//
//This code is copyrighted and has
// limited warranties.Please see http://www.Planet-Source-Code.com/ //for details.
//**************************************
//
'Place this code anywhere on your form code
#Region " ClientAreaMove Handling "
Const WM_NCHITTEST As Integer = &H84
Const HTCLIENT As Integer = &H1
Const HTCAPTION As Integer = &H2
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_NCHITTEST
MyBase.WndProc(m)
If m.Result = HTCLIENT Then m.Result = HTCAPTION
'If m.Result.ToInt32 = HTCLIENT Then m.Result = IntPtr.op_Explicit(HTCAPTION)
'Try this in VS.NET 2002/2003 if the latter line of code doesn't do it... thx to Suhas for the tip.
Case Else
'Make sure you pass unhandled messages back to the default message handler.
MyBase.WndProc(m)
End Select
End Sub
#End Region
Source: http://www.daniweb.com/techtalkforums/thread31022.html
Last Updated:Thursday, September 02, 2010By:alferoSource#
with your OpenID.
If you do not know what OpenID is,