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. How to Convert HDC to CDC?

How to Convert HDC to CDC?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelptutorialquestion
9 Posts 7 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.
  • T Offline
    T Offline
    TooShy2Talk
    wrote on last edited by
    #1

    Hi guyz, Is it possible to convert HDC to CDC? When I pass CDC to other class I use its HDC, CDC->m_hDC this is to perform the process in there. Rather, I need a way to convert HDC to CDC and make some drawing over it. Now I'm encountering a problem integrating a CDC with the returned HDC. I needed the HDC as my background and the CDC for the drawing like lines. If you have an idea please let me know. Thank you

    Z S T H 4 Replies Last reply
    0
    • T TooShy2Talk

      Hi guyz, Is it possible to convert HDC to CDC? When I pass CDC to other class I use its HDC, CDC->m_hDC this is to perform the process in there. Rather, I need a way to convert HDC to CDC and make some drawing over it. Now I'm encountering a problem integrating a CDC with the returned HDC. I needed the HDC as my background and the CDC for the drawing like lines. If you have an idea please let me know. Thank you

      Z Offline
      Z Offline
      zzangcorea
      wrote on last edited by
      #2

      Hi man. I know how to convert it is. show below if your handle is m_hDC, CDC* pCDC = CDC::FromHandle(m_hDC); Ok. You can get the CDC* from m_hDC

      S 1 Reply Last reply
      0
      • Z zzangcorea

        Hi man. I know how to convert it is. show below if your handle is m_hDC, CDC* pCDC = CDC::FromHandle(m_hDC); Ok. You can get the CDC* from m_hDC

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

        That will only work if the HDC is already wrapped by a CDC. To wrap a HDC in a CDC use the CDC::Attach method.

        Steve

        R 1 Reply Last reply
        0
        • T TooShy2Talk

          Hi guyz, Is it possible to convert HDC to CDC? When I pass CDC to other class I use its HDC, CDC->m_hDC this is to perform the process in there. Rather, I need a way to convert HDC to CDC and make some drawing over it. Now I'm encountering a problem integrating a CDC with the returned HDC. I needed the HDC as my background and the CDC for the drawing like lines. If you have an idea please let me know. Thank you

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

          To wrap a HDC in a CDC use the CDC::Attach method. If the HDC is already wrapped by a CDC use the CDC::FromHandle method, as mentioned by the first replier.

          Steve

          L 1 Reply Last reply
          0
          • T TooShy2Talk

            Hi guyz, Is it possible to convert HDC to CDC? When I pass CDC to other class I use its HDC, CDC->m_hDC this is to perform the process in there. Rather, I need a way to convert HDC to CDC and make some drawing over it. Now I'm encountering a problem integrating a CDC with the returned HDC. I needed the HDC as my background and the CDC for the drawing like lines. If you have an idea please let me know. Thank you

            T Offline
            T Offline
            TooShy2Talk
            wrote on last edited by
            #5

            Thank you very much for your replies. I will try this now.

            T 1 Reply Last reply
            0
            • S Stephen Hewitt

              To wrap a HDC in a CDC use the CDC::Attach method. If the HDC is already wrapped by a CDC use the CDC::FromHandle method, as mentioned by the first replier.

              Steve

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              Stephen Hewitt wrote:

              To wrap a HDC in a CDC use the CDC::Attach method. If the HDC is already wrapped by a CDC use the CDC::FromHandle method,

              If Microsoft ever starts documenting that stuff CodeProject traffic would really decrease. ;P

              led mike

              1 Reply Last reply
              0
              • T TooShy2Talk

                Thank you very much for your replies. I will try this now.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                CDC construtor is of any help??

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                Never mind - my own stupidity is the source of every "problem" - Mixture

                cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                1 Reply Last reply
                0
                • T TooShy2Talk

                  Hi guyz, Is it possible to convert HDC to CDC? When I pass CDC to other class I use its HDC, CDC->m_hDC this is to perform the process in there. Rather, I need a way to convert HDC to CDC and make some drawing over it. Now I'm encountering a problem integrating a CDC with the returned HDC. I needed the HDC as my background and the CDC for the drawing like lines. If you have an idea please let me know. Thank you

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

                  And see this[^] thread.

                  1 Reply Last reply
                  0
                  • S Stephen Hewitt

                    That will only work if the HDC is already wrapped by a CDC. To wrap a HDC in a CDC use the CDC::Attach method.

                    Steve

                    R Offline
                    R Offline
                    Rajkumar R
                    wrote on last edited by
                    #9

                    May be i understood wrongly, CDC::FromHandle() "If a CDC object is not attached to the handle, a temporary CDC object is created and attached." from msdn.

                    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