C# Winform 窗体美化(四、镂空窗体)
来源:互联网 发布:两期二叉树模型 知乎 编辑:程序博客网 时间:2024/05/16 12:57
四、镂空窗体
例子下载
直接贴效果图吧:
1、控件的透明
2、窗体的透明
代码如下:
public partial class Form1 : Form{ public Form1() { InitializeComponent(); SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_LAYERED); SetLayeredWindowAttributes(Handle, 0x00FF00, 255, LWA_COLORKEY);//替换某种颜色为透明(0x00FF00:绿色) } private const uint WS_EX_LAYERED = 0x80000;//异形窗体特效的实现 private const int GWL_EXSTYLE = -20;//设定一个新的扩展风格 private const int LWA_COLORKEY = 1;//透明方式 [DllImport("user32", EntryPoint = "SetWindowLong")] //改变指定窗口的属性 private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong); [DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")] //设置分层窗口透明度 private static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, int bAlpha, int dwFlags); private void Form1_Load(object sender, EventArgs e) { //TransparencyKey = BackColor; }}
注意:
TransparencyKey = BackColor;
这句代码可以使窗口透明。
3 0
- C# Winform 窗体美化(四、镂空窗体)
- C# Winform 窗体美化(目录)
- C# Winform 窗体美化(八、Icon)
- C# Winform 窗体美化(三、不规则窗体)
- C# Winform 窗体美化(六、双层窗体)
- C# Winform 窗体美化(九、嵌入窗体)
- C# Winform 窗体美化(十、自定义窗体)
- C# Winform 窗体美化(一、IrisSkin 换肤库)
- C# Winform 窗体美化(二、LayeredSkin 界面库)
- C# Winform 窗体美化(五、鼠标穿透)
- C# Winform 窗体美化(七、Win7 Aero 毛玻璃效果)
- 基于C#的WinForm窗体美化(无须美工功底)
- C#中winform窗体的美化控件 iriskin(一)
- C#中winform窗体的美化控件 iriskin(二)
- Skin控件 C# Winform窗体美化控件
- C# Winform中窗体的美化
- winform窗体美化
- WinForm窗体美化基础(一)
- Spark Job Scheduling
- Tarjan
- C# 13位时间戳
- python模拟掷骰子
- 机器学习算法笔记之5:支持向量机SVM
- C# Winform 窗体美化(四、镂空窗体)
- 尊重个人劳动成果,如果可以请点赞,顶一下,谢谢!
- 2017上半年课程设计递推斐波那契
- java中的值传递和引用传递
- 炒蘑菇
- 百度 echarts 使用总结
- Fragment中传递参数推荐用Fragment.setArguments(Bundle bundle),而不用构造方法。
- VBA入门--变量的基础内容和知识点
- HashMap解决hash冲突的方法