標簽: vc學(xué)習筆記msdn文化 | 分類(lèi): 學(xué)習 |
說(shuō)道CDC類(lèi)就不能不提一下GdiObject---圖形對象類(lèi)。在Windows應用程序中,設備環(huán)境與圖形對象共同工作,協(xié)同完成繪圖顯示工作。就像畫(huà)家繪畫(huà)一樣,設備環(huán)境好比是畫(huà)家的畫(huà)布,圖形對象好比是畫(huà)家的畫(huà)筆。用畫(huà)筆在畫(huà)布上繪畫(huà),不同的畫(huà)筆將畫(huà)出不同的畫(huà)來(lái)。選擇合適的圖形對象和繪圖對象,才能按照要求完成繪圖任務(wù)。
有關(guān)CDC類(lèi)的繼承
父類(lèi):從 CObject 直接繼承而來(lái)。繼承了CObject類(lèi)的各種特性,如動(dòng)態(tài)創(chuàng )建等等。
子類(lèi):CClientDC-------代表操作窗口的DC ,是比較常用的一個(gè)子類(lèi)
CMetaFileDC ------響應Meta File的DC ,Meta File是一些GDI消息。
CPaintDC-------響應WM_PAINT消息的DC。
CWindowDC ------代表整個(gè)屏幕的DC
CDC類(lèi)的數據成員
數據成員只有兩個(gè):
HDC m_hDC : CDC對象使用的輸出設備上下文
HDC m_hAttribDC : CDC對象使用的屬性設備上下文
二者在CDC對象創(chuàng )建時(shí)指向相同的設備上下文。
| CDC | Constructs a CDC object. |
| CreateDC | Creates a device context for a specific device. |
| CreateIC | Creates an information context for a specific device. This provides a fast way to get information about the device without creating a device context. |
| CreateCompatibleDC | Creates a memory-device context that is compatible with another device context. You can use it to prepare images in memory. |
| DeleteDC | Deletes the Windows device context associated with this CDC object. |
| FromHandle | Returns a pointer to a CDC object when given a handle to a device context. If a CDC object is not attached to the handle, a temporary CDC object is created and attached. |
| DeleteTempMap | Called by the CWinApp idle-time handler to delete any temporary CDC object created by FromHandle. Also detaches the device context. |
| Attach | Attaches a Windows device context to this CDC object. |
| Detach | Detaches the Windows device context from this CDC object. |
| SetAttribDC | Sets m_hAttribDC, the attribute device context. |
| SetOutputDC | Sets m_hDC, the output device context. |
| ReleaseAttribDC | Releases m_hAttribDC, the attribute device context. |
| ReleaseOutputDC | Releases m_hDC, the output device context. |
| GetCurrentBitmap | Returns a pointer to the currently selected CBitmap object. |
| GetCurrentBrush | Returns a pointer to the currently selected CBrush object. |
| GetCurrentFont | Returns a pointer to the currently selected CFont object. |
| GetCurrentPalette | Returns a pointer to the currently selected CPalette object. |
| GetCurrentPen | Returns a pointer to the currently selected CPen object. |
| GetWindow | Returns the window associated with the display device context. |
| GetSafeHdc | Returns m_hDC, the output device context. |
| SaveDC | Saves the current state of the device context. |
| RestoreDC | Restores the device context to a previous state saved with SaveDC. |
| ResetDC | Updates the m_hAttribDC device context. |
| GetDeviceCaps | Retrieves a specified kind of device-specific information about a given display device’s capabilities. |
| IsPrinting | Determines whether the device context is being used for printing. |
| GetBrushOrg | Retrieves the origin of the current brush. |
| SetBrushOrg | Specifies the origin for the next brush selected into a device context. |
| EnumObjects | Enumerates the pens and brushes available in a device context. |
| SelectObject | Selects a GDI drawing object such as a pen. |
| SelectStockObject | Selects one of the predefined stock pens, brushes, or fonts provided by Windows. |
Color and Color Palette Functions
| GetNearestColor | Retrieves the closest logical color to a specified logical color that the given device can represent. |
| SelectPalette | Selects the logical palette. |
| RealizePalette | Maps palette entries in the current logical palette to the system palette. |
| UpdateColors | Updates the client area of the device context by matching the current colors in the client area to the system palette on a pixel-by-pixel basis. |
| GetHalftoneBrush | Retrieves a halftone brush. |
| GetBkColor | Retrieves the current background color. |
| SetBkColor | Sets the current background color. |
| GetBkMode | Retrieves the background mode. |
| SetBkMode | Sets the background mode. |
| GetPolyFillMode | Retrieves the current polygon-filling mode. |
| SetPolyFillMode | Sets the polygon-filling mode. |
| GetROP2 | Retrieves the current drawing mode. |
| SetROP2 | Sets the current drawing mode. |
| GetStretchBltMode | Retrieves the current bitmap-stretching mode. |
| SetStretchBltMode | Sets the bitmap-stretching mode. |
| GetTextColor | Retrieves the current text color. |
| SetTextColor | Sets the text color. |
| GetColorAdjustment | Retrieves the color adjustment values for the device context. |
| SetColorAdjustment | Sets the color adjustment values for the device context using the specified values. |
| GetMapMode | Retrieves the current mapping mode. |
| SetMapMode | Sets the current mapping mode. |
| GetViewportOrg | Retrieves the x- and y-coordinates of the viewport origin. |
| SetViewportOrg | Sets the viewport origin. |
| OffsetViewportOrg | Modifies the viewport origin relative to the coordinates of the current viewport origin. |
| GetViewportExt | Retrieves the x- and y-extents of the viewport. |
| SetViewportExt | Sets the x- and y-extents of the viewport. |
| ScaleViewportExt | Modifies the viewport extent relative to the current values. |
| GetWindowOrg | Retrieves the x- and y-coordinates of the origin of the associated window. |
| SetWindowOrg | Sets the window origin of the device context. |
| OffsetWindowOrg | Modifies the window origin relative to the coordinates of the current window origin. |
| GetWindowExt | Retrieves the x- and y-extents of the associated window. |
| SetWindowExt | Sets the x- and y-extents of the associated window. |
| ScaleWindowExt | Modifies the window extents relative to the current values. |
聯(lián)系客服