本文实例讲述了wpf设置窗体可以使用鼠标拖动大小的方法。分享给大家供大家参考。具体实现方法如下:
// 获得窗体的 样式
int oldstyle = nativemethods.getwindowlong(hwnd, nativemethods.gwl_style);
// 更改窗体的样式为无边框窗体
nativemethods.setwindowlong(hwnd, nativemethods.gwl_style, oldstyle & ~nativemethods.ws_caption);
// setwindowlong(hwnd, gwl_exstyle, oldstyle & ~ws_ex_layered);
// 1 | 2 << 8 | 3 << 16 r=1,g=2,b=3 详见winuse.h文件
// 设置窗体为透明窗体
nativemethods.setlayeredwindowattributes(hwnd, 1 | 2 << 8 | 3 << 16, 0, nativemethods.lwa_alpha);
// 创建圆角窗体 12 这个值可以根据自身项目进行设置
nativemethods.setwindowrgn(hwnd, nativemethods.createroundrectrgn(0, 0, convert.toint32(this.actualwidth), convert.toint32(this.actualheight), 12, 12), true);
}
nativemethods.cs的代码:
希望本文所述对大家的wpf程序设计有所帮助。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论