User.GetDC Method

Tao.Platform.Windows SDK Documentation

User.GetDC Method 

The GetDC function retrieves a handle to a display device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC.

The see cref="GetDCEx" /> function is an extension to GetDC, which gives an application more control over how and whether clipping occurs in the client area.

[Visual Basic]
Public Shared Function GetDC( _
   ByVal windowHandle As 
IntPtr  _
) As 
IntPtr
[C#]
public static 
IntPtr  GetDC(
   
IntPtr  windowHandle
);
Parameters
windowHandle

Handle to the window whose DC is to be retrieved. If this value is null, GetDC retrieves the DC for the entire screen.

Windows 98/Me, Windows 2000/XP: To get the DC for a specific display monitor, use the see cref="EnumDisplayMonitors" /> and see cref="Gdi.CreateDC" /> functions.

Return Value

 

If the function succeeds, the return value is a handle to the DC for the specified window's client area.

If the function fails, the return value is null.

Windows NT/2000/XP: To get extended error information, call GetLastWin32Error.

 

Remarks

The GetDC function retrieves a common, class, or private DC depending on the class style of the specified window. For class and private DCs, GetDC leaves the previously assigned attributes unchanged. However, for common DCs, GetDC assigns default attributes to the DC each time it is retrieved. For example, the default font is System, which is a bitmap font. Because of this, the handle for a common DC returned by GetDC does not tell you what font, color, or brush was used when the window was drawn. To determine the font, call see cref="GetTextFace" />.

Note that the handle to the DC can only be used by a single thread at any one time.

After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released. ReleaseDC must be called from the same thread that called GetDC. The number of DCs is limited only by available memory.

Windows 95/98/Me: There are only 5 common DCs available per thread, thus failure to release a DC can prevent other applications from accessing one.

See Also

User Class | Tao.Platform.Windows Namespace | ReleaseDC

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值