Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Device Context.

Device Context.

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    voorugonda prashanth
    wrote on last edited by
    #1

    why CPaintDC not used in other than OnPaint()?

    S 1 Reply Last reply
    0
    • V voorugonda prashanth

      why CPaintDC not used in other than OnPaint()?

      S Offline
      S Offline
      Sarath C
      wrote on last edited by
      #2

      for a WM_PAINT messaege we do the drawings withing BeginPaint and EndPaint. CPaintDC calls BeginPaint at construction time and EndPaint at destruction time. From MSDN: CPaintDC objects encapsulate the common idiom of Windows, calling the BeginPaint function, then drawing in the device context, then calling the EndPaint function. The CPaintDC 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. SaRath.
      _"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."


      My Blog | Understanding State Pattern in C++_

      V 1 Reply Last reply
      0
      • S Sarath C

        for a WM_PAINT messaege we do the drawings withing BeginPaint and EndPaint. CPaintDC calls BeginPaint at construction time and EndPaint at destruction time. From MSDN: CPaintDC objects encapsulate the common idiom of Windows, calling the BeginPaint function, then drawing in the device context, then calling the EndPaint function. The CPaintDC 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. SaRath.
        _"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar."


        My Blog | Understanding State Pattern in C++_

        V Offline
        V Offline
        voorugonda prashanth
        wrote on last edited by
        #3

        hi sarath, why it is not working if i use CPaintDc in onLButtonDown()?

        H 1 Reply Last reply
        0
        • V voorugonda prashanth

          hi sarath, why it is not working if i use CPaintDc in onLButtonDown()?

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Now again i use from MSDN From the MSDN The CPaintDC class is a device-context class derived from CDC_**


          **_

          whitesky


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups