Please support our VB.NET advertiser: Programming Forums
![]() |
i have been using the microsoft visual basic 2005 express edition beta which is my first attempt at doing anything with visual basic so it has been taking me a long time to learn myself how to do things - mainly by using google and also reading through all the posts on forums such as this one.
the thing i am completely stuck on though is that i would like to use a borderless form for the sake of being able to completely control the appearance of my program on the screen but realise that people would want to be able to move it about in the same way that msn messenger can be dragged around the screen using the mouse when the windowframe is hidden.
i have kept copying in different pieces of code from all sorts of websites below are just 2 examples but nothing i have tried works in the current program.
http://www.a1vbcode.com/snippet-316.asp
http://support.microsoft.com/kb/q173773/
does anyone know the solution to this? i will carry on trawling for answers but if someone knows a working set of bits of code i will be very grateful if they could tell me.
the thing i am completely stuck on though is that i would like to use a borderless form for the sake of being able to completely control the appearance of my program on the screen but realise that people would want to be able to move it about in the same way that msn messenger can be dragged around the screen using the mouse when the windowframe is hidden.
i have kept copying in different pieces of code from all sorts of websites below are just 2 examples but nothing i have tried works in the current program.
http://www.a1vbcode.com/snippet-316.asp
http://support.microsoft.com/kb/q173773/
does anyone know the solution to this? i will carry on trawling for answers but if someone knows a working set of bits of code i will be very grateful if they could tell me.
finally , after a whole week of looking , i've found something that works
http://www.planet-source-code.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!3965/lngWId!10/anyname.htm
//**************************************
//
// 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/vb/scripts/Sh
// owCode.asp?txtCodeId=3965&lngWId=10 //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
http://www.planet-source-code.com/URLSEO/vb/scripts/ShowCode!asp/txtCodeId!3965/lngWId!10/anyname.htm
//**************************************
//
// 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/vb/scripts/Sh
// owCode.asp?txtCodeId=3965&lngWId=10 //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
![]() |
Similar Threads
Other Threads in the VB.NET Forum
- vb6 moving frameless form on screen (Visual Basic 4 / 5 / 6)
- How the hell (Visual Basic 4 / 5 / 6)
- Stop printing boxes around forms? (JavaScript / DHTML / AJAX)
- Need Help Urgently (JavaScript / DHTML / AJAX)
- Moving <form></form> to an external file? (HTML and CSS)
Other Threads in the VB.NET Forum
- Previous Thread: ComboBox UpDate Problem
- Next Thread: position of form after moving previous one
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode