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.

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

'past this in your form1 (general) (declarations)

Public Class Form1

Private mouseOffset As Point
Private isMouseDown As Boolean = False
Private Sub Label1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDoubleClick
ColorDialog1.ShowDialog()
Label1.ForeColor = ColorDialog1.Color
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseDown
Dim xOffset As Integer
Dim yOffset As Integer
If e.Button = MouseButtons.Left Then
xOffset = -e.X - SystemInformation.FrameBorderSize.Width
yOffset = -e.Y - SystemInformation.CaptionHeight - _
SystemInformation.FrameBorderSize.Height
mouseOffset = New Point(xOffset, yOffset)
isMouseDown = True
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If isMouseDown Then
Dim mousePos As Point = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseUp
' Changes the isMouseDown field so that the form does
' not move unless the user is pressing the left mouse button.
If e.Button = MouseButtons.Left Then
isMouseDown = False
End If
End Sub
end class

please lets remember to mark thread as solved so people dont keep going through the stress of looking for an already found solution. Am saying this cos am affected

ok thanks but i was lost time to do code & wen i was find soluction i was put here because i was first here search for the code but nothing found & wan i was made iwas create login put code & exit but i was not remember to solve it because i was first time here

in the code somme things you eed change i'mprograming a clock an labels arein thecode to change code you use only mouse down mouse etc... in your picture inside your form i thing this donne because in my form works good i have only a problem i'm using vb 2008 express and windows xp sp3 and the progrms idonne theyd'ont work in windows 7 and vista gives error do you know why need to programming with net framw. 4 ?

pls try to use plain english because some of us can really ready appreviations and slang words

This article has been dead for over six months. Start a new discussion instead.