[MFC] GDI( Graphics Device Interface )

DC( Device Context )
GDI is supported by Windows OS to process the problem from compatibility with new Graphic Cards. If u use GDI, u don't need to care about a kind of devices.
Create DC to choose a device which u r going to use. After creating DC, GDI returns the handler of the DC. Then, u are able to use the device via the handler. U must release DC, after using the DC. Or else, Memory Leak occurs.

MFC DC( Device Context )
The below illustration is MFC Class Table.

CObject--
              |-- CDC
                 |-- CClientDC
                 |-- CMetaFileDC
                 |-- CPaintDC
                 |-- CWindowDC

1) CDC Class
CDC Class is the base class of other DC classes. In MFC Application, CWnd::GetDC Func returns CDC class pointer. After painting via the CDC pointer, u must release the DC using CWnd::ReleaseDC Func.

2) CWindowDC Class
It's for the entire region of Window. It contains Caption Bar, Menu Bar, Tool Bar, State Bar and so on... ,and besides Client region, that is, the entire region of Window.
GetWindowDC Func returns DC and ReleaseDC Func releases DC.

3) CClientDC Class
It's for client region in a Window. ClientDC Func returns DC and ReleaseDC FUnc releases DC or U could use delete with the pointer for DC.
ex ) CClientDC* pClientDC = new CClientDC( this );
       delete pClientDC;

4) CPaintDC Class
It's used in OnPaint Member Func which is WM_PAINT Message handler Func, when a window is being redrawed by WM_PAINT message. CPaintDC dc(this)  Func gets a pointer of Paint DC.

5) CMetaFileDC Class
It manages DC which are related with MetaFile( WMF, EMF ). MetaFile is a file of a group of GDI commands.

'Programming > Windows Programming' 카테고리의 다른 글

라디오 버튼 그룹지정 하기  (0) 2009.08.22
IP HELP API 설정하기  (0) 2009.08.22
[MFC] 더블 버퍼링  (0) 2009.06.22
[MFC] Bitmap Object  (0) 2009.06.07
[MFC] FileOpen  (0) 2009.06.04

설정

트랙백

댓글