DC --> device context (device environment ).
It is an abstraction of a Specific Drawing Object. A dc is a structure at the underlying layer of windows.
In a Windows Multi-task environment. AProgramThe output of program B cannot be affected, so every program is strictly limited to its own window. GDI uses a simple mechanism to ensure that each program is drawn and executed in a specific environment. This mechanism is device context (DC ).
So you can see that if you want to draw in a specific window, you must use the handle of this window as a parameter to obtain its drawing environment (DC ). Then you can paint on it.
In fact, the "A specific window" I mentioned above is not accurate. Because you will find that you can only draw in the customer area of the window. However, it cannot be drawn in its window and title bar. In fact, this also reflects the concept of DC.
If you want to draw the entire form, you must use getwindowdc (hwnd) to obtain the device environment of the entire form.
Finally, do not forget to release the system resource releasedc (hwnd, HDC) after drawing ).