Red Security

Full Version: vb.net diamond shaped form by rotating a square
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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

 [attachment=124]