วันอังคารที่ 22 ตุลาคม พ.ศ. 2562

Create Windows Forms Application circular


How to create circular form 


Figure 1 Circular form


Figure 2 Normal form


Steps for creating a circular form

1.Create new project windows form application visual basic
2.Create Sub CircularForm,btnCircular_Click,Form1_SizeChanged

Dim Circular As Boolean
Dim WidthLast, HeightLast As Integer
Private Sub CircularForm(ByVal obj As Form)
        Try
            Circular = True
            Dim DGP As New Drawing2D.GraphicsPath
            DGP.StartFigure()
            System.Threading.Thread.Sleep(0)
           
            Me.Size = New System.Drawing.Size(Me.Height, Me.Height)
            'End If
            txtWidth.Text = "" & Convert.ToInt32(obj.Width).ToString + " px ," & "" + "" + Convert.ToInt32(obj.Width * 0.264583333).ToString + " mm"
            txtHeight.Text = "" & Convert.ToInt32(obj.Height).ToString + " px , " & "" + "" + Convert.ToInt32(obj.Height * 0.264583333).ToString + " mm"
            obj.BackColor = Color.Orange


            DGP.AddArc(New Rectangle(0, 0, (obj.Width / 1), (obj.Height / 1)), 180, 360)
            DGP.CloseFigure()

            obj.Region = New Region(DGP)
            WidthLast = Me.Width
            HeightLast = Me.Height
        Catch ex As Exception

        End Try
    End Sub

Private Sub btnCircular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCircle.Click
        Try
            CircularForm(Me)
        Catch ex As Exception

        End Try
    End Sub


Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
        Try
            
                CircularForm(Me)
        
            WidthLast = Me.Width
            HeightLast = Me.Height
        Catch ex As Exception

        End Try

    End Sub

When finished, can test immediately.






ไม่มีความคิดเห็น:

แสดงความคิดเห็น

Create Windows Forms Application circular

How to create  circular  form  Figure 1  Circular form Figure 2  Normal form Steps for creating a circular form ...