function function:
The GetDC function user obtains the device environment handle for the client area or entire screen of the specified window, and then you can use the handle in the GDI function to draw in the device environment.
A device environment is an undisclosed data structure whose values are used internally by GDI functions.
Gets the handle of the device called GetDC, first declares
Private Declare Function GetDC Lib "user32" (ByVal hwnd as long) as long
Parameter resolution:
| Parameters |
Meaning |
| HWnd |
1. The specified window handle 2. If the value is NULL, get the entire screen of the device environment |
return value:
1. If the function call succeeds, the return value is the device environment handle for the client area of the specified window;
2. If the function call fails, the return value is NULL.
Example
Get the device handle for a form
Option Explicit
Private Declare Function GetDC Lib "user32" (ByVal hwnd as long) as long
Private Sub Command1_Click ()
Dim Formhdc as Long
FORMHDC = GetDC (Form1.hwnd)
Print FORMHDC
End Sub
It's so easy! Continue to update in ...
VB API First Lesson GETDC call