How to move form without the title bar?

Hi,

I have a problem on my application, i have an image an set it as form, and I set the form borderstyle to none, the problem is, i can't move the form.

Can u help me pls :(



Answer this question

How to move form without the title bar?

  • Christopher_N

     cgraus wrote:

     

    write your own code to move the form if the user clicks and drags.

     

    Definately. Yup.



  • SeanBenjaminC

    In Visual Basic 6, I can move the form using the Win32API ReleaseCapture, but in Visual Basic Express i can't


  • jalekz

    I wrote functions to handle moving of borderless windows and posted it here: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=82889&SiteID=1

    Although it's in C#, you can easily convert it to VB.NET.

    Cheers,

    -chris

  • Ndt

    The following code controls a circle form, boderstyle = none, that can be moved:

    Public Class Form3

    Private mouseOffset As Point

    Private isMouseDown As Boolean = False

    ' This allows the user to double click the form and close it

    Private Sub Form3_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick

    Me.Close()

    End Sub

    Private Sub Form3_MouseDown(ByVal sender As Object, _

    ByVal e As MouseEventArgs) Handles MyBase.MouseDown

    Dim xOffset As Integer

    Dim yOffset As Integer

    If e.Button = Windows.Forms.MouseButtons.Left Then

    xOffset = -e.X - SystemInformation.FrameBorderSize.Width

    yOffset = -e.Y - SystemInformation.FrameBorderSize.Height

    mouseOffset = New Point(xOffset, yOffset)

    isMouseDown = True

    End If

    End Sub

    Private Sub Form3_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

    ' This uses a contextmenu to allow a right click close option

    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click

    Me.Close()

    End Sub

    Private Sub Form3_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp

    isMouseDown = False

    End Sub

    Protected Overrides Sub OnPaint( _

    ByVal e As System.Windows.Forms.PaintEventArgs)

    Dim shape As New System.Drawing.Drawing2D.GraphicsPath

    e.Graphics.DrawImage(My.Resources.Sara_and_Eric, 0, 0)

    shape.AddEllipse(100, 100, 600, 600)

    Me.Region = New System.Drawing.Region(shape)

    End Sub

     

     

     

    End Class



  • Adam Wagman

    You can right click on the program in the task bar, select move and use your arrows. Or you can write your own code to move the form if the user clicks and drags.



  • How to move form without the title bar?