Windows API 之SetWindowPos
来源:互联网 发布:淘宝店铺请替换该图片 编辑:程序博客网 时间:2024/06/06 19:23
SetWindowPos 可以改变窗体位置
引用:
/// <summary> /// 该函数改变一个窗口的大小、坐标、垂直顺序 /// </summary> /// <param name="hWnd">目标窗口句柄</param> /// <param name="hWndInsertAfter">枚举值(垂直顺序)</param> /// <param name="x">x坐标</param> /// <param name="y">y坐标</param> /// <param name="Width">宽</param> /// <param name="Height">高</param> /// <param name="flags">枚举</param> /// <returns></returns> [DllImport("user32.dll", CharSet = CharSet.Auto)] static public extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int Width, int Height, uint flags);
hWndInsertAfter 枚举值:
/// <summary> /// hWndInsertAfter 枚举 /// </summary> public enum WindowsZOrder { HWND_BOTTOM = 1, HWND_NOTOPMOST = -2, HWND_TOP = 0, HWND_TOPMOST = -1 }
Windows flags 枚举:
public enum WindowsFlags { //flags 参数可选值: SWP_ASYNCWINDOWPOS = 0x4000, //若调用进程不拥有窗口, 系统会向拥有窗口的线程发出需求 SWP_DEFERERASE = 0x2000, //防止产生 WM_SYNCPAINT 消息 SWP_DRAWFRAME = 0x0020, //画边框 SWP_FRAMECHANGED = 0x0020, //强制发送 WM_NCCALCSIZE 消息, 一般只是在改变大小时才发送此消息 SWP_HIDEWINDOW = 0x0080, //隐藏窗口 SWP_NOACTIVATE = 0x0010, //不激活 SWP_NOCOPYBITS = 0x0100, //丢弃客户区 SWP_NOMOVE = 0x0002, //忽略 X、Y, 不改变位置 SWP_NOOWNERZORDER = 0x0200, //忽略 hWndInsertAfter, 不改变 Z 序列的所有者 SWP_NOREDRAW = 0x0008, //不重绘 SWP_NOREPOSITION = 0x0200, //忽略 hWndInsertAfter, 不改变 Z 序列的所有者 SWP_NOSENDCHANGING = 0x0400, //不发出 WM_WINDOWPOSCHANGING 消息 SWP_NOSIZE = 0x0001, //忽略 cx、cy, 保持大小 SWP_NOZORDER = 0x0004, //忽略 hWndInsertAfter, 保持 Z 顺序 SWP_SHOWWINDOW = 0x0040 //显示窗口 }
调用时,可先获取当前屏幕工作区域,已方便设置宽和高,例如:
Screen currentScreen = Screen.FromHandle((IntPtr)); //多屏时可以获取当前屏幕System.Drawing.Rectangle currentRectangle = currentScreen.WorkingArea;
int widht = currentRectangle.Width;
int height = crrentRectangle.Height;
- Windows API 之SetWindowPos
- Windows API : SetWindowPos
- Windows API SetWindowPos
- Windows API SetWindowPos祥解(摘抄)
- SetWindowPos API
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- Windows API一日一练(38)SetWindowPos函数
- 雨中飘荡的回忆
- 如何做好用户体验(三) ---- 内容篇
- solr DataImportHandler 解决mysql 表导入内存溢出问题
- flex的mxml 文件在eclipse下不能自动编译的问题
- Extjs上传附件实战开发,实现批量上传及在线预览功能(一)
- Windows API 之SetWindowPos
- ckeditor/ckfinder配置
- 关于socket的一些初步研究
- 做空机构的黑与白
- archlinux下ibus使用搜狗的词库
- oracle9i、10g、11g区别
- eclipse几个版本的命名
- 末日的爱情
- 构建自己的C/C++插件开发框架(四)——核心层设计和实现