Simple way to create transparent borders like Vista/windows 7 in XP with vb.net
It’s a trick.
First you need two forms that is form1(default form of project) and add new form(it will be form2)
then set color to form1(as you like) and set its opacity to 80%
Make sure that both forms Formborderstyle set as None
then
put the following code into form1:
Public Class Form1
Dim xx, yy As Integer
Dim iMouseDown As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Form2.Visible = True
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
iMouseDown = 1
xx = e.X : yy = e.Y
Me.Cursor = Cursors.NoMove2D
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If iMouseDown = 1 Then
If e.X > xx Then
Me.Left = Me.Left + 1
Form2.Left = Form2.Left + 1
End If
If e.X < xx Then
Me.Left = Me.Left - 1
Form2.Left = Form2.Left - 1
End If
If e.Y > yy Then
Me.Top = Me.Top + 1
Form2.Top = Form2.Top + 1
End If
If e.Y < yy Then
Me.Top = Me.Top - 1
Form2.Top = Form2.Top - 1
End If
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
iMouseDown = 0
Me.Cursor = Cursors.Default
End Sub
Private Sub frmClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles frmClose.Click
Application.Exit()
End Sub
End Class
after that put following code into form2 load event:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Height = Form1.Height - 60
Me.Left = Me.Left + 10
Me.Width = Me.Width - 20
End Sub
You can add some controls to form2 like:now Run Project
Thank you