Cambalinho Posted March 30, 2012 at 09:33 PM Report #446728 Posted March 30, 2012 at 09:33 PM eu ja pesquisei muita coisa, mas sem sucesso:( eu sei que o Visual Basic 2010 não suporta verdadeira transparencia(esconder 1 cor do usercontrol\controles). mas tenho 1 codigo que simula isso. mas o problema é quando movo o objecto, porque demora mesmo muito para aparecer transparente:( eis o meu codigo actual para transparencia: 'Put the control transparent Public Property Transparent As Boolean Get Return blnTransparent End Get Set(ByVal value As Boolean) blnTransparent = value Me.UpdateStyles() Me.Update() End Set End Property Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams cp.ExStyle = cp.ExStyle Or &H20 'WS_EX_TRANSPARENT Return cp End Get End Property Public Sub New() MyBase.New() InitializeComponent() Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True) Me.UpdateStyles() End Sub 'Draw it's image Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs) 'do not allow the background to be painted End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) If Me.BackgroundImage Is Nothing Then Exit Sub If Transparent = False Then MyBase.OnPaintBackground(e) Else Dim a As Bitmap a = Me.BackgroundImage If Transparent = True Then a.MakeTransparent() e.Graphics.DrawImageUnscaled(a, New Point()) e.Dispose() End If End Sub alguem me pode dar 1 sugestao?(sem falar de WPF)
mateusb Posted April 1, 2012 at 01:03 PM Report #446869 Posted April 1, 2012 at 01:03 PM existe sim! é só escrever assim: Me.Opacity = TrackBar1.Value / 100 coloque uma trackbar no form, depois, mude as propriedades para: Maximun = 100 Value = 100 quando debugar, arraste a trackbar para ver... não foi usado nenhum user control
ribeiro55 Posted April 1, 2012 at 01:27 PM Report #446873 Posted April 1, 2012 at 01:27 PM Esconder uma cor não é verdadeira transparência 😉 Só WPF brinca com verdadeira transparência (canal Alpha). É algo trivial para WPF pois ele está desenhado precisamente para responder a necessidades estéticas em primeira instância. Esse não é o intuito de WinForms, nunca foi, nem vai ser. Qualquer artifício elaborado nesse sentido, ou falha miserávelmente ou é impraticável. Acho que há uma forma qualquer de render controlos WPF em WinForms, apesar de não me parecer muito bem... já que arrastas essa parte da framework, para quê os WinForms? Acho que a verdadeira questão que se coloca aqui é porque razão afastas peremptoriamente o WPF, se queres brincadeiras com transparência? Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips"
mateusb Posted April 3, 2012 at 10:09 PM Report #447378 Posted April 3, 2012 at 10:09 PM Fiz um vídeo sobre isso, http://visualbandeira.blogspot.com.br/2012/04/opacidade-do-formulario.html
ribeiro55 Posted April 3, 2012 at 10:32 PM Report #447383 Posted April 3, 2012 at 10:32 PM mateusb, eu acho que ele se refere, ou a transparência entre controlos, ou a verdadeiro mapa de opacidade, onde consegues obter diferentes níveis de opacidade em áreas diferentes, como por exemplo num PNG. Não se está a referir à opacidade do form, onde com a propriedade opacity apenas obténs a escala alpha de forma uniforme. Por exemplo, WPF aceita PNG como mapa de opacidade. É possível fazer janelas como a que vês quando inicias o Visual Studio, que anexo abaixo. Repara que não se trata de um form menos ou mais opaco: trata-se de uma janela com uma área completamente opaca e outra completamente transparente. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips"
mateusb Posted April 4, 2012 at 05:52 PM Report #447556 Posted April 4, 2012 at 05:52 PM fiquei curioso e tentei fazer uma splashscreen transparente... Mesmo com um gif transparente e o BackColor = transparent, não consegui a maldita splashscreen transparente. ? Mas de qualquer forma, vocês poderiam me falar mais sobre WPF? Gostaria de saber como fazer a transparência entre controles...
programadorvb6 Posted May 19, 2012 at 02:26 PM Report #456850 Posted May 19, 2012 at 02:26 PM (edited) Tente assim, não sei se é a + indicada : Public Class Pic_Transparente Inherits System.Windows.Forms.PictureBox Private Property Define_Transparencia As Boolean Public Property Transparencia As Boolean Get Return Define_Transparencia End Get Set(ByVal value As Boolean) Define_Transparencia = value Me.UpdateStyles() Me.Update() End Set End Property Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams cp.ExStyle = cp.ExStyle Or &H20 'WS_EX_TRANSPARENT Return cp End Get End Property Public Sub New() MyBase.New() Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True) Me.SetStyle(ControlStyles.ResizeRedraw, True) Me.SetStyle(ControlStyles.UserPaint, True) Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False) Me.UpdateStyles() End Sub 'Draw it's image Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs) End Sub Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) If Me.BackgroundImage Is Nothing Then Exit Sub If Transparencia = False Then MyBase.OnPaintBackground(e) Else Dim a As Bitmap a = Me.BackgroundImage If Transparencia = True Then a.MakeTransparent() e.Graphics.DrawImageUnscaled(a, New Point()) e.Dispose() End If End Sub End Class Edited May 19, 2012 at 02:52 PM by programadorvb6 ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé.
programadorvb6 Posted May 19, 2012 at 03:49 PM Report #456860 Posted May 19, 2012 at 03:49 PM Ou então para um splashscreen. Usas uma imagem Png Em seguida colocas este código : Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim m_Bitmap As New Bitmap(Me.Width, Me.Height) Using g As Graphics = Graphics.FromImage(m_Bitmap) g.CopyFromScreen(Me.Location, Point.Empty, Me.Size) g.DrawImage(My.Resources.nome_da_imagem_de_fundo, 0, 0, Me.Width, Me.Height) End Using Me.BackgroundImage = m_Bitmap End Sub End Class ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now