.NET/Windows API for .NET

GetWindowDC - 현재 Windows화면의 Device Context 구하기

클리엘 2019. 7. 31. 14:23
728x90

GetWindowDC는 지정된 Windows화면에 대한 Device Context를 구하는 함수입니다.

Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Integer) As Integer

- VB.NET 선언

[DllImport("user32")]
public static extern int GetWindowDC(int hwnd);

- C# 선언

GetWindowDC(handle)

- VB.NET 호출

GetWindowDC(handle);

- C# 호출

 

GetWindowDC함수의 인수로는 해당 Device Context를 구할 Windows화면의 Handle을 넘겨주면 됩니다. 이때 만일 현재 화면에 대한 Device Context를 구하려면 GetDesktopWindow함수를 사용하면 됩니다.

[Windows API for .NET] - GetDesktopWindow - 현재 Windows 화면의 Handle구하기

 

Device Context는 Windows화면에 대한 Font나 Graphic등의 다양한 정보가 담긴 일종의 구조체이며 이 정보를 바탕으로 다른 API 함수에서 화면표시나 Graphic제어를 수행합니다.

이 함수는 만일 실행에 실패하는 경우 0을 반환합니다.

728x90