日期:2014-05-20  浏览次数:20818 次

除了API外,有没有C#2005中有没有方法改变窗口位置?
我做的程序,调用另外的一个EXE程序,会生成一个新窗口,但是由于该窗口无法拖拽,因此需要程序控制其位置.

C#中有没有相应的方法?如果没有,只好用API喽.

------解决方案--------------------
如果这个exe 程序是独立 的,好像没有内置的方法,可用API,如果是你程序中 的,设置position属性即可!
------解决方案--------------------
如果你是用Process来打开的那个程序,你可以通过Process.MainWindowHandle 属性 来得到那个程序的主窗口句柄,然后通过API来调整这个窗口:
[DllImport( "user32.dll ", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);