用户绘制的控件正在使用以前的表单背景
我在表单上有几个用户绘制的控件,不幸的是,当显示表单时,用户绘制的控件显示以前的表单背景而不是当前的表单背景。
OnPaint事件很简单,OnBackgroundPaint事件是空的...
像这样:
protected override void OnPaint(PaintEventArgs pe)
{
pe.Graphics.DrawImageUnscaled(_bmpImage, 0, 0);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
//Leave empty...
}
如何让当前背景成为显示的透明度,而不是之前窗体的背景?
I have several user drawn controls on a form, unfortunately when the form is shown the user drawn controls are showing the previous forms background rather than the current forms background.
The OnPaint event is very simple, and the OnBackgroundPaint event is empty...
Like this:
protected override void OnPaint(PaintEventArgs pe)
{
pe.Graphics.DrawImageUnscaled(_bmpImage, 0, 0);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
//Leave empty...
}
How do I get the current background to be the transparency that is shown, rather than the background of the previous form?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要设置窗口样式 - 这是一个 不错的基本样式文章。
You need to set the window style - here's a nice basic article.
您似乎正在重写
OnPaintBackground
方法,不对背景执行任何操作。 由于您将其留空,因此您可能不应该首先覆盖它。 当您让默认的 OnPaintBackground 处理程序完成其工作时会发生什么? 难道不应该自动正确绘制当前控件的背景吗?PS 我从未使用过自定义绘画.Net 控件。 我只是猜测,试图帮助找到解决您问题的方法。 如果我的建议完全不对,请原谅我......
You seem to be overriding the
OnPaintBackground
method not do anything about the background. Since you're leaving it empty, you probably shouldn't override it in the first place. What happens when you just let the defaultOnPaintBackground
handler do its job? Shouldn't that automatically draw the current control's background properly?P.S. I've never worked with custom painting .Net controls. I'm merely speculating in an attempt to help find a solution to your problem. Forgive me if what I'm suggesting is completely off...