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. Am I doing wrong?

Am I doing wrong?

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
6 Posts 4 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.
  • P Offline
    P Offline
    ppatel567
    wrote on last edited by
    #1

    Hi, In View I get DC as CDC *dc = GetDC(); I do whatever.. and function exits.. Is there need to release this dc or it will be done automatically as function exits.. If I release will there be harm to views DC. What is the right way. SHould I always use CClientDC in views rather than CDC regards ppatel

    M 1 Reply Last reply
    0
    • P ppatel567

      Hi, In View I get DC as CDC *dc = GetDC(); I do whatever.. and function exits.. Is there need to release this dc or it will be done automatically as function exits.. If I release will there be harm to views DC. What is the right way. SHould I always use CClientDC in views rather than CDC regards ppatel

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      From the docs:

      Unless the device context belongs to a window class, the ReleaseDC member function must be called to release the context after painting.

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

      P 1 Reply Last reply
      0
      • M Michael Dunn

        From the docs:

        Unless the device context belongs to a window class, the ReleaseDC member function must be called to release the context after painting.

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

        P Offline
        P Offline
        ppatel567
        wrote on last edited by
        #3

        How can I know if the device context belongs to windows? Which function/syntax shows that dc belongs to windows? ppatel

        S 1 Reply Last reply
        0
        • P ppatel567

          How can I know if the device context belongs to windows? Which function/syntax shows that dc belongs to windows? ppatel

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          The simple answer is don't bother. Here's a quote from MSDN on the ReleaseDC function:  "The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs." So always call ReleaseDC and let the system worry about the details. Steve

          H 1 Reply Last reply
          0
          • S Stephen Hewitt

            The simple answer is don't bother. Here's a quote from MSDN on the ReleaseDC function:  "The ReleaseDC function releases a device context (DC), freeing it for use by other applications. The effect of the ReleaseDC function depends on the type of DC. It frees only common and window DCs. It has no effect on class or private DCs." So always call ReleaseDC and let the system worry about the details. Steve

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

            Hi Stephen Hewitt and use DeleteDC() if use CreateCompatibleDC or CreateDC:)_**


            **_

            WhiteSky


            S 1 Reply Last reply
            0
            • H Hamid Taebi

              Hi Stephen Hewitt and use DeleteDC() if use CreateCompatibleDC or CreateDC:)_**


              **_

              WhiteSky


              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              From doco on DeleteDC  "An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC." If you use CreateCompatibleDC of CreateDC you need to delete it when done by calling DeleteDC. Calling ReleaseDC doesn't actually delete a DC. To quote again from MSDN:  "The ReleaseDC function releases a device context (DC), freeing it for use by other applications." Steve

              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