CDC,CPaintDC,CWindowDC,CClientDC

它们之间的的关系如下:

CObject 

public |------CDC 
public |------|------CClientDC 
public |------|------CPaintDC 
public |------|------CWindowDC 

public |------|------CMetaFileDC 


CDC

msdn上关于CDC是这样描述的

The CDC object provides member functions for working with a device context, such as a display or printer, as well as members for working with a display context associated with the client area of a window.

(翻译:CDC对象提供用于处理设备上下文的成员函数,例如显示器或打印机,以及用于处理与窗口的客户区域相关联的显示上下文的成员。)

可以使用GetDC() 来获取设备的DC。同时,在使用完后,记得调用ReleaseDC()来释放DC

CPaintDC

It performs a CWnd::beginpaint at construction time and CWnd::EndPaint at destruction time.A CPaintDC object can only be used when responding to a WM_PAINT message, usually in your OnPaint message-handler member function.

(翻译:它在构造时调用CWnd :: BeginPaint,在析构时CWnd :: EndPaint结束。CPaintDC对象只能在响应WM_PAINT消息时使用,通常在您的OnPaint消息处理程序成员函数中。)

来处理窗口的绘制消息

CClientDC

This means that the device context associated with a CClientDC object is the client area of a window.

(翻译:这意味着与CClientDC对象相关联的设备上下文是窗口的客户端区域。)

其构造函数中包含了GetDC,析构函数中包含了ReleaseDC。所以在每次显示的去调用它们。


CWindowDC

Calls the Windows function GetWindowDC()at construction time and ReleaseDC() at destruction time. This means that a CWindowDC object accesses the entire screen area of a CWnd (both client and nonclient areas).

(翻译:在构建时调用Windows函数GetWindowDC,并在析构时调用ReleaseDC。这意味着一个CWindowDC对象访问CWnd的整个屏幕区域(客户端和非客户端区域))

CWindowDC 和CClientDC一样。不需要显示的去调用GetDC和ReleaseDC函数。CWindowDC可以访问整个窗口区域,包括了客户区和非客户区。

其中,CPaintDC和CClientDC的坐标原点是位于客户区的左上角。而CWindowDC的坐标原点是位于屏幕的左上角。CpaintD




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值