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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CDC exist or not question

CDC exist or not question

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 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.
  • E Offline
    E Offline
    econy
    wrote on last edited by
    #1

    Hi, in a program, I want to judge if a CDC object is exist, or NULL. don't know how can I do it. Thanks in advance for any suggestions

    E J 2 Replies Last reply
    0
    • E econy

      Hi, in a program, I want to judge if a CDC object is exist, or NULL. don't know how can I do it. Thanks in advance for any suggestions

      E Offline
      E Offline
      econy
      wrote on last edited by
      #2

      can I use m_hDC == NULL to decide it?

      CPalliniC 1 Reply Last reply
      0
      • E econy

        can I use m_hDC == NULL to decide it?

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        In a clean scenario, it should be enough.

        Veni, vidi, vici.

        In testa che avete, signor di Ceprano?

        E 1 Reply Last reply
        0
        • CPalliniC CPallini

          In a clean scenario, it should be enough.

          Veni, vidi, vici.

          E Offline
          E Offline
          econy
          wrote on last edited by
          #4

          I am kind of not understand what is a clean scenario. did you mean a clean scenario, the m_hDC is NULL?

          CPalliniC 1 Reply Last reply
          0
          • E econy

            I am kind of not understand what is a clean scenario. did you mean a clean scenario, the m_hDC is NULL?

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            For instance, messing MFC with WINAPI is NOT a clean scenario: you could call ::DeleteDC(m_hDC) and then the GDI object would exist no more but m_hDC would be NOT NULL.

            Veni, vidi, vici.

            In testa che avete, signor di Ceprano?

            E 1 Reply Last reply
            0
            • CPalliniC CPallini

              For instance, messing MFC with WINAPI is NOT a clean scenario: you could call ::DeleteDC(m_hDC) and then the GDI object would exist no more but m_hDC would be NOT NULL.

              Veni, vidi, vici.

              E Offline
              E Offline
              econy
              wrote on last edited by
              #6

              Tested, set break point, it seems m_hDC, the member variable of CDC, if CDC object was not initialized, it is NULL.

              CPalliniC 1 Reply Last reply
              0
              • E econy

                Tested, set break point, it seems m_hDC, the member variable of CDC, if CDC object was not initialized, it is NULL.

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #7

                OK. That's not a proof, of course, however it is reassuring.

                Veni, vidi, vici.

                In testa che avete, signor di Ceprano?

                1 Reply Last reply
                0
                • E econy

                  Hi, in a program, I want to judge if a CDC object is exist, or NULL. don't know how can I do it. Thanks in advance for any suggestions

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #8

                  My preferred method is to call CDC::GetSafeHdc() and test the return value for NULL.

                  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