用消息来进行重绘后,其他控件的BackColor = Color.Transparent不起作用了。怎么解决这个问题。
用消息来进行重绘后,其他控件的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);
}
}
用
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);
}
}
...全文
相关推荐
winform panel控件背景透明
winform panel控件背景透明 在网页中通过div+css实现半透明效果不难,今天我们看看一种在winfrom中实现的方法
改变MFC对话框背景色、控件内的字体
改变MFC对话框背景色、控件内的字体颜色和背景色 设置 Dialog, Group Box, Static Text, Check Box, Edit Ctrl(disabled), Combo Box(disabled), Radio Button等背景色 编写WM_CTLCOLOR消息的映射函数OnCtlColor(CDC *pDC, CWnd pWnd, UINT nCtlColor)
winform 透明控件
winform 透明控件 C# .net
VB.NET自定义控件设置背景色透明
尝试将VB.NET自定义控件的背景色设置为透明,且不遮住下面的控件。
在.NET Compact Framework中创建透明控件
本文介绍了如何在.NET Compact Framework中创建透明控件


