Usuário com melhor resposta
Arredondamento das bordas.

Pergunta
-
Olá,
Eu uso o seguinte codigo para arredondar as bordas do form.
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Integer, ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer) As Integer Private Sub fm_main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim regionHandle As IntPtr = New IntPtr(CreateRoundRectRgn(0, 0, Me.Width, Me.Height, 50, 50)) Me.Region = Region.FromHrgn(regionHandle) End Sub
Ele arredonda todos os 4 cantos do form.
mas eu gostaria de saber como posso arredondar somente a parte de cima, somente os 2 cantos de cima, ( Title bar )
Respostas
-
Segue código de exemplo.
Imports System.Drawing.Drawing2D Public Class Form1 Sub ArredondaCantosdoForm() Dim PastaGrafica As New GraphicsPath Dim rect As New Rectangle(1, 1, Me.Size.Width, Me.Size.Height) PastaGrafica.AddRectangle(rect) 'Arredondar canto superior esquerdo Dim rES As New Rectangle(1, 1, 10, 10) PastaGrafica.AddRectangle(rES) PastaGrafica.AddPie(1, 1, 20, 20, 180, 90) 'Arredondar canto superior direito Dim rDS As New Rectangle(Me.Width - 12, 1, 12, 13) PastaGrafica.AddRectangle(rDS) PastaGrafica.AddPie(Me.Width - 24, 1, 24, 26, 270, 90) 'Arredondar canto inferior esquerdo '' '' ''Dim rIE As New Rectangle(1, Me.Height - 10, 10, 10) '' '' ''PastaGrafica.AddRectangle(rIE) '' '' ''PastaGrafica.AddPie(1, Me.Height - 20, 20, 20, 90, 90) 'Arredondar canto inferior direito '' '' ''Dim rID As New Rectangle(Me.Width - 12, Me.Height - 13, 13, 13) '' '' ''PastaGrafica.AddRectangle(rID) '' '' ''PastaGrafica.AddPie(Me.Width - 24, Me.Height - 26, 24, 26, 0, 90) PastaGrafica.SetMarkers() Me.Region = New Region(PastaGrafica) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ArredondaCantosdoForm() End Sub End Class
A parte do código que arredonda as boras inferiores estão comentadas, se quiser utilizar basta descomentar.
Leonardo Garcia
pensouweb@hotmail.com- Marcado como Resposta Eduardo Henrique Antunes quinta-feira, 7 de março de 2013 01:27
Todas as Respostas
-
Segue código de exemplo.
Imports System.Drawing.Drawing2D Public Class Form1 Sub ArredondaCantosdoForm() Dim PastaGrafica As New GraphicsPath Dim rect As New Rectangle(1, 1, Me.Size.Width, Me.Size.Height) PastaGrafica.AddRectangle(rect) 'Arredondar canto superior esquerdo Dim rES As New Rectangle(1, 1, 10, 10) PastaGrafica.AddRectangle(rES) PastaGrafica.AddPie(1, 1, 20, 20, 180, 90) 'Arredondar canto superior direito Dim rDS As New Rectangle(Me.Width - 12, 1, 12, 13) PastaGrafica.AddRectangle(rDS) PastaGrafica.AddPie(Me.Width - 24, 1, 24, 26, 270, 90) 'Arredondar canto inferior esquerdo '' '' ''Dim rIE As New Rectangle(1, Me.Height - 10, 10, 10) '' '' ''PastaGrafica.AddRectangle(rIE) '' '' ''PastaGrafica.AddPie(1, Me.Height - 20, 20, 20, 90, 90) 'Arredondar canto inferior direito '' '' ''Dim rID As New Rectangle(Me.Width - 12, Me.Height - 13, 13, 13) '' '' ''PastaGrafica.AddRectangle(rID) '' '' ''PastaGrafica.AddPie(Me.Width - 24, Me.Height - 26, 24, 26, 0, 90) PastaGrafica.SetMarkers() Me.Region = New Region(PastaGrafica) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ArredondaCantosdoForm() End Sub End Class
A parte do código que arredonda as boras inferiores estão comentadas, se quiser utilizar basta descomentar.
Leonardo Garcia
pensouweb@hotmail.com- Marcado como Resposta Eduardo Henrique Antunes quinta-feira, 7 de março de 2013 01:27
-
Segue código de exemplo.
Imports System.Drawing.Drawing2D Public Class Form1 Sub ArredondaCantosdoForm() Dim PastaGrafica As New GraphicsPath Dim rect As New Rectangle(1, 1, Me.Size.Width, Me.Size.Height) PastaGrafica.AddRectangle(rect) 'Arredondar canto superior esquerdo Dim rES As New Rectangle(1, 1, 10, 10) PastaGrafica.AddRectangle(rES) PastaGrafica.AddPie(1, 1, 20, 20, 180, 90) 'Arredondar canto superior direito Dim rDS As New Rectangle(Me.Width - 12, 1, 12, 13) PastaGrafica.AddRectangle(rDS) PastaGrafica.AddPie(Me.Width - 24, 1, 24, 26, 270, 90) 'Arredondar canto inferior esquerdo '' '' ''Dim rIE As New Rectangle(1, Me.Height - 10, 10, 10) '' '' ''PastaGrafica.AddRectangle(rIE) '' '' ''PastaGrafica.AddPie(1, Me.Height - 20, 20, 20, 90, 90) 'Arredondar canto inferior direito '' '' ''Dim rID As New Rectangle(Me.Width - 12, Me.Height - 13, 13, 13) '' '' ''PastaGrafica.AddRectangle(rID) '' '' ''PastaGrafica.AddPie(Me.Width - 24, Me.Height - 26, 24, 26, 0, 90) PastaGrafica.SetMarkers() Me.Region = New Region(PastaGrafica) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ArredondaCantosdoForm() End Sub End Class
A parte do código que arredonda as boras inferiores estão comentadas, se quiser utilizar basta descomentar.
Leonardo Garcia
pensouweb@hotmail.comFuncionou perfeitamente !
Muito obrigado Leonardo.Garcia.