[VB2010]-用户控制透明和opacy的能力 [英] [VB2010] - usercontrol transparent and opacy habilaty

查看:48
本文介绍了[VB2010]-用户控制透明和opacy的能力的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,如果vb2010如此强大,为什么我不能在控件上拥有真正的透明性?:(

so if vb2010 is so powerfull, why i can't have real Transparency on controls?:(

我有1个代码可使用户控件透明:

i have 1 code for make the usercontrol transparent:

'Put the control transparent
    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()
        If Transparent = True Then
            Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
            Me.UpdateStyles()
        End If
    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)
        Dim a As Bitmap

        a = Me.BackgroundImage
        If Transparent = True Then
            MyBase.OnPaint(e)
        End If

        e.Graphics.DrawImageUnscaled(a, New Point())
        e.Dispose()
    End Sub

目前,我有1个问题:在显示图像之前,控件需要很长时间进行自我更新:(

for now, i have 1 problem: the control needs very time to update itself, before shows the image:(

该控件保持透明,但是当我移动它时,该控件显示其透明的速度很慢:(

the control stays transparent, but when i move it, the control is slow to show itself transparent:(

如何避免这些问题?

推荐答案

如果我正确记住透明度是0到1之间的值,则0是完全透明的,而1是透明的完全牢固.

If I remember correctly transparency is a value from 0 to 1 0 being completely transparent and 1 being completely solid.



这篇关于[VB2010]-用户控制透明和opacy的能力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆