原先代码为:
uint ExdStyle = GetWindowLong(this.Handle, GWL_EXSTYLE);
SetWindowLong(this.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
SetLayeredWindowAttributes(this.Handle, 0x000000, 120, 3);
为了不显示图标在任务栏,所以在后面又加了一行代码:
this.ShowInTaskbar = false;
加完后发现图标是不显示在任务栏上了,但是窗体也变得不透明了,猜测有可能是添加的代码将原有窗体的属性参数给弄乱了,故又调整了一下顺序:
this.ShowInTaskbar = false;
uint ExdStyle = GetWindowLong(this.Handle, GWL_EXSTYLE);
SetWindowLong(this.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
SetLayeredWindowAttributes(this.Handle, 0x000000, 120, 3);
再试了一下,一切ok