如何获取panel容器里控件的句柄
答案:2 悬赏:60 手机版
解决时间 2021-03-03 09:01
- 提问者网友:容嬷嬷拿针来
- 2021-03-02 17:37
如何获取panel容器里控件的句柄
最佳答案
- 五星知识达人网友:妄饮晩冬酒
- 2021-03-02 18:53
1.可以使用Spy++找到你想监控的窗口的类名和标题名,通过这两个参数获取监控窗口的句柄
IntPtr hWnd = FindWindow("#32770", "文件另存为"); 02
2.通过Spy++,展开窗口树上的各个节点直到你要的控件,并且参考节点的顺序使用FindWindowEx函数从窗口句柄开始一级一级的往里找到你要的控件的句柄,下面的代码行是要找到【文件另存为】对话框内文件名的输入框,并且通过发消息来自动填入内容。
IntPtr hChild;
hChild = FindWindowEx(hWnd,IntPtr.Zero, "DUIViewWndClassName",String.Empty);
hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", String.Empty); hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink",String.Empty); hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", String.Empty); hChild = FindWindowEx(hChild, IntPtr.Zero, "Edit", String.Empty);02
SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, "c:\1.txt");
以上就是监控其他程序panel的思路。
IntPtr hWnd = FindWindow("#32770", "文件另存为"); 02
2.通过Spy++,展开窗口树上的各个节点直到你要的控件,并且参考节点的顺序使用FindWindowEx函数从窗口句柄开始一级一级的往里找到你要的控件的句柄,下面的代码行是要找到【文件另存为】对话框内文件名的输入框,并且通过发消息来自动填入内容。
IntPtr hChild;
hChild = FindWindowEx(hWnd,IntPtr.Zero, "DUIViewWndClassName",String.Empty);
hChild = FindWindowEx(hChild, IntPtr.Zero, "DirectUIHWND", String.Empty); hChild = FindWindowEx(hChild, IntPtr.Zero, "FloatNotifySink",String.Empty); hChild = FindWindowEx(hChild, IntPtr.Zero, "ComboBox", String.Empty); hChild = FindWindowEx(hChild, IntPtr.Zero, "Edit", String.Empty);02
SendMessage(hChild, WM_SETTEXT, IntPtr.Zero, "c:\1.txt");
以上就是监控其他程序panel的思路。
全部回答
- 1楼网友:毛毛
- 2021-03-02 19:34
思路是这样的.得有三个变量.
记录x坐标: int xpos;
记录y坐标: int ypos;
记录是否按下鼠标: bool moveflag;
//在picturebox的鼠标按下事件里,记录三个变量.
private void picbox_mousedown(object sender, mouseeventargs e)
{
moveflag = true;//已经按下.
xpos = e.x;//当前x坐标.
ypos = e.y;//当前y坐标.
}
//在picturebox的鼠标按下事件里.
private void picbox_mouseup(object sender, mouseeventargs e)
{
moveflag = false;
}
//在picturebox鼠标移动
private void picbox_mousemove(object sender, mouseeventargs e)
{
if (moveflag)
{
picbox.left += convert.toint16(e.x - xpos);//设置x坐标.
picbox.top += convert.toint16(e.y - ypos);//设置y坐标.
}
}
这样就可以实现控件在容器里的移动
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯