업데이트 : 또한 체크 아웃 할 수 있습니다 윈폼 'NativeWindow
class, 기본 HWWND
을 포장하고 해당 창에 전송 윈도우 메시지에 들어하는 데 사용 될 수있다.
나는 당신이 당신의 창 B의 위치 (및 크기)합니다 (HWND
일)을 설정하려면 Win32 API 함수 MoveWindow
필요합니다 가정합니다. .NET via P/Invoke에서이 API 함수를 호출 할 수 있습니다.
창 B의 현재 위치와 크기를 검색하려면 P/Invoke를 통해 GetWindowRect
으로 전화해야 할 수도 있습니다.
다음 코드는 상자 밖으로 작동하지 않을 수 있습니다, 그리고 어쩌면 간단한 해결책이있다, 그러나 함께 위의 링크와 함께, 당신에게 출발점을 줄 수 있습니다
// the following P/Invoke signatures have been copied from pinvoke.net:
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd,
int X, int Y,
int nWidth, int nHeight,
bool bRepaint);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(HandleRef hWnd, out RECT lpRect);
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}
...
System.Windows.Form a = ...;
IntPtr b = ...;
RECT bRect;
GetWindowRect(b, out bRect);
MoveWindow(b,
a.Location.X + 50, b.Location.Y,
bRect.Right - bRect.Left, bRect.Bottom - bRect.Top,
true);
+1 많이 좋아합니다. –
많이 좋아합니다. 지금 당장은 테스트 할 수 없지만, 오늘 밤에는 너무 많이 땜질하지 않고 작동한다면 받아 들일 수 있습니다. 감사! – Lazlo