Hi Shoban
The following solution is a basic one. I think you are using Windows Forms. The idea behind is we have to work around the Paint Event of the Form.
1) Goto the Form's Paint event.
2) Create a Graphical path object.
3) Add rectangles and lines
4) Set the Form's region using the Graphical path.
Code below
Public mouse_offset As Point
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim p As System.Drawing.Drawing2D.GraphicsPath = New _
System.Drawing.Drawing2D.GraphicsPath()
p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
p.AddLine(40, 0, Me.Width - 40, 0)
p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, 40), 0, 90)
p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
Me.Region = New Region(p)
p.Dispose()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
mouse_offset = New Point(-e.X, -e.Y)
End Sub
Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim mousepos As Point
If e.Button = Windows.Forms.MouseButtons.Left Then
mousepos = Control.MousePosition
mousepos.Offset(mouse_offset.X, mouse_offset.Y)
Location = mousepos
End If
End Sub
Private Sub Label1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
mouse_offset = New Point(-e.X, -e.Y)
End Sub
Also in the design
1) Put a label and Dock to top
2) Set the Form's border style as None.
3) Set some nice background color for the label and form.
Sorry it is not my code. I copied from various urls.
Please look this code, it is nice one too. But using another approch : http://www.codeproject.com/KB/cs/customforms.aspx
Thanks
Anuraj P
http://www.dotnetthoughts.net
THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.