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

「已注销」 「已注销」 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
用消息来进行重绘后,其他控件的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);
}
}
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
「已注销」
C# 111,129 成员 642,538 内容