.NET/Windows API for .NET

GetDC - Window및 Control의 Device Context 구하기

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

GetDC함수는 인수로 전달한 특정 Window나 Control의 Device Context 값을 반환합니다.

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

- VB.NET 선언

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

- C# 선언

 

함수의 인수로는 Device Context값을 구할 Window나 Control의 Handle을 지정하면 됩니다. 예를 들어 Program에서 실행할 Form의 Device Context를 구하는 경우라면 다음과 같이 함수를 호출할 수 있습니다.

Dim idc As Integer
idc = GetDC(Me.Handle)

- VB.NET 호출

int idc;
idc = GetDC((int)this.Handle);

- C# 호출

728x90