程序运行时如何避免用户控制变得透明? [英] How to avoid user control to be transparent the instant when the program is running?

查看:109
本文介绍了程序运行时如何避免用户控制变得透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!

伙计们,我的用户控件存在此问题.
我在这里有一个用户控件,该控件具有这样的方法和示例:

Good day!

Guys, i have this problem with my user control.
I have here a user control that has a method and oveerides like these:

protected void InvalidateEx()
        {
            if(Parent == null)
                return ;
            Rectangle rc = new Rectangle(this.Location, this.Size);
            Parent.Invalidate(rc, true);
        }


protected override void OnPaintBackground(PaintEventArgs e){ }

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x00000020; //WS_EX_TRANSPARENT
        InvalidateEx();
        return cp;
    }
}



我的问题是,每当我运行程序时,初始显示都是透明的,但是每当发生某个事件(例如具有此事件中编码的特定代码的Form_Move事件)时,用户控件就会以透明背景显示.那我该怎么办?我已经尝试对事件进行相同的代码行,以允许用户控件出现在formload中,但仍然无法正常工作.请帮忙.
如果您需要我的整个用户控制程序/我的表单代码,请在此处对其进行注释.谢谢! :)



My problem is that whenever I run my program, the initial display is transparent but whenever a certain event(e.g. Form_Move event with a specific codes encoded in this event) will happen, the usercontrol will appear with a transparent background. What should I do then? I''ve tried doing the same code lines with respect to the events that allow the usercontrol to appear in the formload but it still didnt work. Please help.
If you need my whole user control program / my form code, please comment it here. Thanks! :)

推荐答案

您覆盖了OnPaintBackground方法,并且没有提供任何代码来绘制背景或调用基类OnPaintBackground,因此请猜测是什么?永远不会发生...
You overrode the OnPaintBackground method and didn''t provide any code in it to either paint the background or call the base class OnPaintBackground, so guess what''s not going to happen, ever...


这篇关于程序运行时如何避免用户控制变得透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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