c# 将获取了句柄的窗体移动到某一位置

liuqilin1987 2010-10-23 09:27:57
我通过 [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
获取到了某个窗体的的句柄。
现在我希望通过某个方法将该窗体移动到(0,0)位置,应该怎么做?
可不可以通过SendMessage来做?这样又应该怎么做?
...全文
355 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-10-23
  • 打赏
  • 举报
回复
FindWindow找到对话框,然后MoveWindow移动
[DllImport( "user32.dll" )]
private static extern IntPtr FindWindow( string a , string b );
[DllImport( "user32.dll" )]
public static extern bool SetWindowPos(
IntPtr hWnd , // 窗口句柄
IntPtr hWndInsertAfter , // 排列顺序的句柄
int X , // 水平坐标
int Y , // 垂直坐标
int cx , // 宽
int cy , // 高
uint uFlags // 窗口定位标示
);

GetWindowRect(句柄, ref Rect);
SetWindowPos(句柄, new IntPtr(-1), Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, 0);
threenewbee 2010-10-23
  • 打赏
  • 举报
回复
MoveWindow()
SetWindowPos()

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧