Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
Public Shared Function GetWindowDC(ByVal hWnd As IntPtr) As IntPtr
Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any window is not recommended. The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title bar, menu, and scroll bars. The GetDC function can be used to retrieve a device context for the entire screen.
After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device context has serious effects on painting requested by applications.
Tips & Tricks:
For .NET Compact Framework, change user32.dll to coredll.dll
Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _
nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _
As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Boolean
Private Const SRCCOPY As Integer = &HCC0020
Declare Function GetWindowDC Lib "user32" (ByVal hwnd As IntPtr) As IntPtr
' Get an image of the form plus its decoration
' (borders, title bar, etc).
Private Function GetDecoratedFormImage() As Bitmap
' Get this form's Graphics object.
Dim MyGrph As Graphics = Me.CreateGraphics
' Make a Bitmap to hold the image.
Dim TempBMP As New Bitmap(Me.Width, Me.Height, MyGrph)
Dim MyGrphBmp As Graphics = MyGrph.FromImage(TempBMP)
Dim MyGrphBmpHdc As IntPtr = MyGrphBmp.GetHdc
' Get the form's hDC. We must do this after
' creating the new Bitmap, which uses me_gr.
Dim MyGrphHdc As IntPtr = GetWindowDC(Me.Handle)
' BitBlt the form's image onto the Bitmap.
BitBlt(MyGrphBmpHdc, 0, 0, Me.Width, Me.Height, MyGrphHdc, 0, 0, SRCCOPY)
' Return the result.
Alternative Managed API:
Do you know one? Please contribute it!
Retrieves various system metrics of display elements and system configuration settings.
4/21/2009 1:37:08 PM - -18.104.22.168
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).