zoukankan      html  css  js  c++  java
  • Device Contexts, CDC, CPaintDC,CClientDC,CWindowDC,CMetaFileDC

    http://msdn.microsoft.com/en-us/library/azz5wt61(v=vs.80).aspx

    A device context is a Windows data structure containing information about the drawing attributes of a device such as a display or a printer. All drawing calls are made through a device-context object, which encapsulates the Windows APIs for drawing lines, shapes, and text. Device contexts allow device-independent drawing in Windows. Device contexts can be used to draw to the screen, to the printer, or to a metafile.

    CPaintDC objects encapsulate the common idiom of Windows, calling the BeginPaint function, then drawing in the device context, then calling the EndPaint function. TheCPaintDC constructor calls BeginPaint for you, and the destructor calls EndPaint. The simplified process is to create the CDC object, draw, and destroy the CDC object. In the framework, much of even this process is automated. In particular, your OnDraw function is passed a CPaintDC already prepared (via OnPrepareDC), and you simply draw into it. It is destroyed by the framework and the underlying device context is released to Windows upon return from the call to your OnDraw function.

    CClientDC objects encapsulate working with a device context that represents only the client area of a window. The CClientDC constructor calls the GetDC function, and the destructor calls the ReleaseDC function. CWindowDC objects encapsulate a device context that represents the whole window, including its frame.

    CMetaFileDC objects encapsulate drawing into a Windows metafile. In contrast to the CPaintDC passed to OnDraw, you must in this case call OnPrepareDC yourself.

    Mouse Drawing

    Most drawing in a framework program — and thus most device-context work — is done in the view's OnDraw member function. However, you can still use device-context objects for other purposes. For example, to provide tracking feedback for mouse movement in a view, you need to draw directly into the view without waiting for OnDraw to be called.

    In such a case, you can use a CClientDC device-context object to draw directly into the view.

  • 相关阅读:
    Docker 学习笔记
    Docker 镜像加速器(如何加速下载)
    Simple-DQN代码的理解笔记
    c语言NULL和0区别及NULL详解
    C 语言的 const 指针,指针的const有什么不同
    Edge和Level触发的中断
    尚硅谷设计模式笔记-适配器模式
    nginx服务器部署dist文件夹
    nginx服务器部署dist文件夹
    Jexl表达式引擎-根据字符串动态执行JAVA.md
  • 原文地址:https://www.cnblogs.com/wucg/p/2357586.html
Copyright © 2011-2022 走看看