Recently in the GDI part of C #, I tried to write a subtitle control (in fact, it is more appropriate to use a label), but found that the control with GDI to paint the entire control seems not good (should be my level), so I went to the next WIN32 DLL, Discovering the API is really a happy thing (said on the WIN32 platform only). Back in C #, in C # to be in a form (the control is also a form), just use the
Graphics g= control name. CreateGraphics ();//So you can use G to draw something on this control.
But if I want to open the range, draw on the whole screen, then. NET is powerless. Fortunately, we have WIN32, we can use GETDC or CreateDC to get the entire screen of the device drive handle. Don't forget to release it with ReleaseDC or DELETEDC when you're done.
The following are the declaration methods for GetDC () and ReleaseDC () in C #
[System.Runtime.InteropServices.DllImport ( )] static extern IntPtr GetDC (IntPtr Hwnd); // [System.Runtime.InteropServices.DllImport ( " )] static extern int ReleaseDC ( IntPtr hWnd, IntPtr HDC);
Then we get the device drive handle for the entire screen
    HDC = GetDC ( IntPtr.Zero); A device drive handle that returns the entire screen when the incoming pointer is empty
Hey, we can use this device driver handle to scribble things, but before we do this, we'll start with this C # Uncommon things translate into familiar graphics. We just use the
graphics g = GRAPHICS.FROMHDC (HDC);//This is obtained from the device driver handle. NET only graphics class.
Get these things, the rest will not need me to say more, these people can be on this screen love how to draw on how to draw. But remember to call ReleaseDC () to release the handle after the drawing is finished (it doesn't matter if you finish drawing the program).
releasedc (IntPtr.Zero, HDC); //the device driver handle on this screen is released.