vb.net diamond shaped form by rotating a square - Printable Version +- Red Security (https://redsecurity.info/cc) +-- Forum: Programming (https://redsecurity.info/cc/forumdisplay.php?fid=5) +--- Forum: Visual Basic & .NET Framework (https://redsecurity.info/cc/forumdisplay.php?fid=17) +--- Thread: vb.net diamond shaped form by rotating a square (/showthread.php?tid=1028) |
vb.net diamond shaped form by rotating a square - viruss - 04-07-2019 vb.net diamond shaped from <code> Public Class Form1 Private IsFormBeingDragged As Boolean = False Private MouseDownX As Integer Private MouseDownY As Integer Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then IsFormBeingDragged = True MouseDownX = e.X MouseDownY = e.Y End If End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp If e.Button = MouseButtons.Left Then IsFormBeingDragged = False End If End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove If IsFormBeingDragged Then Dim temp As Point = New Point() temp.X = Me.Location.X + (e.X - MouseDownX) temp.Y = Me.Location.Y + (e.Y - MouseDownY) Me.Location = temp temp = Nothing End If End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim pen1 As New Pen(Color.Red, 10) e.Graphics.RotateTransform(45.0F) e.Graphics.FillRectangle(Brushes.Black, New Rectangle(350, -80, 420, 420)) e.Graphics.RotateTransform(-90.0F) e.Graphics.DrawRectangle(pen1, -290, 400, 320, 320) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class </code> no image this time form1 property set: backcolor : red formborderstyle:none transparency red diamondshape.zip (Size: 74 KB / Downloads: 270) |