.NET/Windows API for .NET

GetWindow - 지정한 Window와의 관계 Window찾기

클리엘 2019. 8. 5. 17:34
728x90

GetWindow함수는 지정한 특정 Window로 부터 관계된 Window의 Handle을 반환합니다.

Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer

- VB.NET 선언

[DllImport("user32")]
public static extern int GetWindow(int hwnd, int wCmd);

- C# 선언

 

GetWindow함수의 첫번째 인수는 관계 Window를 찾을 주 Window의 Handle을 지정하고 두번째 인수에서 지정한 Window와 어떤 관계에 있는 Window를 찾을 것인지를 지정합니다.

이때 어떤 관계의 Window를 찾을지는 아래 표를 참고하여 주시기 바랍니다.

 상수  값  설명
 GW_HWNDFIRST  0  최상위 Window를 찾는다.
 GW_HWNDLAST  1  최하위 Window를 찾는다.
 GW_HWNDNEXT  2  하위 Window를 찾는다.
 GW_HWNDPREV  3  상위 Window를 찾는다.
 GW_OWNER  4  부모 Window를 찾는다.
 GW_CHILD  5  자식 Window를 찾는다.

만일 현재 Form의 자식 Window를 찾으려면 GetWindow함수는 다음과 같이 호출할 수 있습니다.

GetWindow(Me.Handle, 5)

- VB.NET 호출

GetWindow((int)this.Handle, 5);

- C# 호출

728x90