簡介
CDC是MFC的DC的一個類
hDC是DC的句柄,API中的一個類似指針的數據類型.
MFC類的前綴都是C開頭的
H開頭的大多數是句柄
這是為了助記,是編程讀\寫代碼的好的習慣.
CDC中所有MFC的DC的基類.常用的CClientDC dc(this);就是CDC的子類(或稱派生類).
CDC等設備上下文類,都含有一個類的成員變數:m_hDc,用來保存與該類相關的句柄.其道理與CWnd類提供m_Wnd成員變數保存與視窗相關的句柄是一樣的。
記住下面的一句話,會有助於你的理解.
DC(設備描述表)在c++中的解釋
設備描述
設備上下文允許在 Windows 中進行與設備無關的繪製。設備上下文可用於繪製到螢幕、印表機或者圖元檔案。
Device Contexts
A device context is a structure that defines a set of graphic objects and their associated attributes, as well as the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a palette for defining the set of available colors, a region for clipping and other operations, and a path for painting and drawing operations. The remainder of this section is divided into the following three areas.