I wanna make simple form application with FormBorderStyle set to None, but the problem is I cant move this form, its just.. static? I wanna make something like this: http://i.imgur.com/TlQCWJx.png
Any ideas how to fix it?
I wanna make simple form application with FormBorderStyle set to None, but the problem is I cant move this form, its just.. static? I wanna make something like this: http://i.imgur.com/TlQCWJx.png
Any ideas how to fix it?
You can use code like this to make the form draggable:
Public Class Form1
Private Const HTCLIENT As Integer = &H1
Private Const HTCAPTION As Integer = &H2
Private Const WM_NCHITTEST As Integer = &H84
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If m.Msg = WM_NCHITTEST AndAlso m.Result = HTCLIENT Then
m.Result = HTCAPTION
End If
End Sub
End Class
You could take a look at WPF. It's a newer version of WinForms and you have much more possibilities to design your dialogs.
But it's also very different to WinForms. You will need time to find into WPF.
Here's a very simple example of moving a borderless form to get you started:
Add a panel to your form, name it pnlTopBorder
and dock it to the top. When you mousedown on the panel, capture the mouse position. When you mousemove on the panel, if the left button is pressed, then you calculate and set the new form position.
Public Class Form1
Private newpoint As System.Drawing.Point
Private xpos1 As Integer
Private ypos1 As Integer
Private Sub pnlTopBorder_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles pnlTopBorder.MouseDown
xpos1 = Control.MousePosition.X - Me.Location.X
ypos1 = Control.MousePosition.Y - Me.Location.Y
End Sub
Private Sub pnlTopBorder_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles pnlTopBorder.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
newpoint = Control.MousePosition
newpoint.X -= (xpos1)
newpoint.Y -= (ypos1)
Me.Location = newpoint
End If
End Sub
End Class
If you want the window title and form controls, you'll have to draw them in the Paint event and handle all the events to get them to work. It's all doable, but it's just more complex.