用消息来进行重绘后,其他控件的BackColor = Color.Transparent不起作用了。怎么解决这个问题。

wllllll 2012-12-01 05:21:32
用消息来进行重绘后,其他控件的BackColor = Color.Transparent不起作用了。怎么解决这个问题。


this.BackgroundImage = Resource.test;
this.BackgroundImageLayout = ImageLayout.Stretch;
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
来解决背景的问题是不错的,但是我可能要更复杂的动作,应该怎么解决。



public partial class Form1 : Form {
public oForm() {
Label aLabel = new Label();
aLabel.AutoSize = true;
aLabel.BackColor = Color.Transparent;
aLabel.Location = new Point(67, 84);
aLabel.Size = new Size(137, 48);
aLabel.Text = "label1aaaaaaaaaa\r\ndsdddddddddddd\ndddddddd\r\nddddddddd";
this.Controls.Add(aLabel);
}

protected override void WndProc(ref Message m) {
if (m.Msg == 13) {
using (Graphics g = this.CreateGraphics()) {
g.DrawImage(Resource.test, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);
}
return;
}
base.WndProc(ref m);
}
}
...全文
282 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
(☆随缘☆) 2012-12-08
  • 打赏
  • 举报
回复
来捧个场,
wllllll 2012-12-08
  • 打赏
  • 举报
回复
回复一下啦,好结贴
rayyu1989 2012-12-08
  • 打赏
  • 举报
回复
wllllll 2012-12-07
  • 打赏
  • 举报
回复
我勒个靠啊,围观群众都没有吗

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧