如题:
怎么让两个自定义控件,上面放图片,两控件叠加,让上面的控件的背景色透明不影响下面的图片显示?
谁能帮忙,想好久了 !

解决方案 »

  1.   

    控件背静透明?那控件就不能整体隐藏了,winform的可能好做一点,重绘下控件就可以了,如果是web的,透明的效果有点难,因为一透明就整个控件就都透明了
      

  2.   

    有意义的 啊!
    两个图片一个框,一个是内容,叠起来就 有了呗!
    有人说用 SetLayeredWindowAttribute 
    但小子才疏学浅,搞不懂!
      

  3.   

    你可以用png格式的图片试试。再不行就试试js
      

  4.   

    主要是想要一种幻灯片的感觉,几个透明的图叠加在一起,在屏幕上显示!
    我主要是做LED屏幕的
      

  5.   

     class AlphaBlend
        {
            // Methods
            public AlphaBlend()
            {
            }        public void AlphaBlendNumber(IntPtr Handle, short Num)
            {
                AlphaBlend.SetLayeredWindowAttributes(Handle, 0, (byte)Num, 2);
            }        public void AlphaBlendPercent(IntPtr Handle, short Percent)
            {
                AlphaBlend.SetLayeredWindowAttributes(Handle, 0, (byte)Math.Round((double)((((double)Percent) / 100) * 255)), 2);
            }        public IntPtr FindApplicationWindow([Optional] string WindowClass /* = null */, [Optional] string WindowTitle /* = null */)
            {
                return AlphaBlend.FindWindow(WindowClass, WindowTitle);
            }        [DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
            private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);        [DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
            private static extern int GetWindowLong(IntPtr Handle, int nIndex);        public void ResetAlphaBlending(IntPtr Handle)
            {
                int num1 = AlphaBlend.GetWindowLong(Handle, -20);
                // The following line has me stumped, in VB, the const WS_EX_LAYERED breaks down to the value 524288
                // Yet on the line below is the same number but increased by one, basically it should (boolean here) num1 and not WS_EX_LAYERED
                AlphaBlend.SetWindowLong(Handle, -20, num1 & -524289);
            }        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
            private static extern int SetLayeredWindowAttributes(IntPtr Handle, int crKey, byte bAlpha, int dwFlags);        public void SetupAlphaBlending(IntPtr Handle)
            {
                int num1 = AlphaBlend.GetWindowLong(Handle, -20);
                num1 |= WS_EX_LAYERED;
                AlphaBlend.SetWindowLong(Handle, -20, num1);
            }        [DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
            private static extern int SetWindowLong(IntPtr Handle, int nIndex, int dwNewLong);
            // Fields
            private const short GWL_EXSTYLE = -20;
            private const short LWA_ALPHA = 2;
            private const short LWA_COLORKEY = 1;
            private const int WS_EX_LAYERED = 0x80000;    }
    这个我用了一下,用form的handle就可以,但是用控件的handle没反应,难道只能重绘么?
    重绘的话,我的控件是能移动的估计肯定要闪屏啊 !