複製鏈接
請複製以下鏈接發送給好友

GetWindowDC

鎖定
GetWindowDC函數:返回hWnd參數所指定的窗口的設備環境。
中文名
GetWindowDC
性    質
指定的窗口的設備環境
相    關
需要調用ReleaseDC釋放設備環境
類    型
函數

目錄

GetWindowDC簡介

獲得的設備環境覆蓋了整個窗口(包括非客户區),例如標題欄、菜單、滾動條,以及邊框。這使得程序能夠在非客户區域實現自定義圖形,例如自定義標題或者邊框。當不再需要該設備環境時,需要調用ReleaseDC函數釋放設備環境。注意,該函數只獲得通用設備環境,該設備環境的任何屬性改變都不會反映到窗口的私有或者類設備環境中(如果窗口有的話)!

GetWindowDC函數原型

HDC GetWindowDC(HWNDhWnd // 窗口句柄);
api函數名(function):GetWindowDC
GetWindowDC 別名(alias):
GetWindowDC 庫名(library):User32
GetWindowDC 操作系統(os):Requires Windows NT 3.1 or later; Requires Windows 95 or later
GetWindowDC 參數表(parameter):
hwnd ----------- Long,將獲取其設備場景的窗口?
hWndIdentifies the window with a device context that is to be retrieved.
GetWindowDC 返回值(return):
Long,執行成功為窗口設備場景,失敗則為0
If the function succeeds, the return value is the handle of a device context for the specified window. If the function fails, the return value is NULL, indicating an error or an invalid hWnd parameter.
GetWindowDC 説明(description):
獲取整個窗口(包括邊框、滾動條、標題欄、菜單等)的設備場景
The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. A window device context permits painting anywhere in a window, because the origin of the device context is the upper-left corner of the window instead of the client area.
GetWindowDC 聲明(declare):
Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long) As Long GetWindowDC 例程(example):
Draw On ScreenWindowFromPointUsing Small Fonts
GetWindowDC .net對應函數(dotnet):
System.Windows.Forms.Form.CreateGraphics.GetHdc
GetWindowDC .net例程(dotnetexample):
GetWindowDC 相關函數(related):
GetDCWindowFromDC
不推薦在vb裏使用這個函數。用完後一定要用ReleaseDC函數釋放場景