C#SetWindowsPos和MoveWindow无法移动窗口 [英] C# SetWindowsPos and MoveWindow fails to move a window

查看:974
本文介绍了C#SetWindowsPos和MoveWindow无法移动窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨;我需要以编程方式移动可执行窗口.我已经编写了一个小型测试程序,可以轻松地将诸如记事本"之类的内容移动到但是我还有另一个可执行文件,拒绝移动或调整大小.这是在新的Windows 10 Enterprise系统上 我正在使用VS2015.我要移动并调整大小的程序可以通过抓住顶部的条并移动它并抓住右下角来完成,您可以像调整任何普通程序一样调整其大小.有趣的是它实际上 认为它已经移动了窗户.恰当的例子:将程序说在屏幕的右下角.您希望它位于左上角,即0,0,尺寸为width = 1200和height =600.现在,您运行的代码应将其移动并调整大小 就像记事本一样,但是图像停留在右下角.您查询该程序,它会报告一个RECT,该RECT正确于宽度和高度为0,0和1200,600的原点,但是图像没有移动!现在,您将鼠标移至上方 屏幕的0,0,1200,600区域,它表示存在某些内容,但它只是空白屏幕.我相信我要尝试操纵的该程序是用c ++编写的,已经存在了很多年.任何人对什么都有任何想法 需要触摸才能真正移动并调整其大小????

Hi; I need to programmatically move an executable window. I have written a small test program and I can easily move things like "notepad" but I have another executable that refuses to move or resize. This is on a new Windows 10 Enterprise system and I am using VS2015. This program that I am trying to move and resize can be accomplished by grabbing the top bar and move it and by grabbing the lower right corner and you can resize it just like any normal program. The interesting thing is it actually thinks it has moved the window. Case in point: you position the program say in lower right on the screen. You want it to be located in the upper left i.e. 0,0 and a size of width = 1200 and height = 600. Now you run the code that should move it and resize it just like it did for notepad but the image stays in the lower right. You query the program and it reports back a RECT that is correct for the origin at 0,0 and 1200,600 width and height, but the image did not move! Now you take the mouse and move it over the 0,0,1200,600 area of the screen and it indicates something is there but it is just empty screen. This program that I am trying to manipulate, I believe was written in c++ and it has been around for a number of years. Anyone have any ideas on what needs to be touched to really move and resize this thing?????

推荐答案

调用

Call SetWindowPos to move a window.

可以通过获取窗口的句柄 FindWindowEx .

Getting the handle for the window can be done with FindWindowEx.


这篇关于C#SetWindowsPos和MoveWindow无法移动窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆