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. Error assigning values?!!

Error assigning values?!!

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
15 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.
  • A AlexO

    In relese that assigment might be optimized, so it is not surprizing you do not see it. As for the exception the code below might show you the problem raner wrote:_

    pView = (CMy3027View*)pMF->GetActiveView();

    if(0 == pView)

    MsgBox("This is  the problem");

    _

    R Offline
    R Offline
    raner
    wrote on last edited by
    #4

    oh yah, i do get the "This is the problem" message box..but what does it mean?;P

    A 1 Reply Last reply
    0
    • J Joao Paulo Figueira

      Downcasts are always unsafe. Are you sure that the CView* returned by GetActiveView() is a CMy3027View*? If it's not, the program may bomb...

      R Offline
      R Offline
      raner
      wrote on last edited by
      #5

      i don't know how to see that the returned pointer is a CMy3027View*..but i've only one CView-derived class so i thought it should be?

      J 1 Reply Last reply
      0
      • R raner

        oh yah, i do get the "This is the problem" message box..but what does it mean?;P

        A Offline
        A Offline
        AlexO
        wrote on last edited by
        #6

        it means the GetActiveView() stopped worked in your program. Check carefully what it does (if you have source control check what it used to do)

        R 1 Reply Last reply
        0
        • R raner

          i don't know how to see that the returned pointer is a CMy3027View*..but i've only one CView-derived class so i thought it should be?

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #7

          Try to use a dynamic_cast. If the returned value is NULL, then the pointer is not of that class.

          R 1 Reply Last reply
          0
          • A AlexO

            it means the GetActiveView() stopped worked in your program. Check carefully what it does (if you have source control check what it used to do)

            R Offline
            R Offline
            raner
            wrote on last edited by
            #8

            what is source control?...i thought it simply gets the MainFrame pointer and then the active view's pointer? anyway...i don't understand how GetActiveView() can just stop working?

            1 Reply Last reply
            0
            • J Joao Paulo Figueira

              Try to use a dynamic_cast. If the returned value is NULL, then the pointer is not of that class.

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

              How do i use dynamic_cast?...sorry,i've heard of it but i've never tried anything like that..

              J 1 Reply Last reply
              0
              • R raner

                How do i use dynamic_cast?...sorry,i've heard of it but i've never tried anything like that..

                J Offline
                J Offline
                Joao Paulo Figueira
                wrote on last edited by
                #10

                Do this:

                pView = dynamic_cast<CMy3027View*>(pMF->GetActiveView());
                if(pView)
                m_numOfValues= pView->m_imageIndex;

                You might have to turn on the RTTI option in VC.

                R 1 Reply Last reply
                0
                • J Joao Paulo Figueira

                  Do this:

                  pView = dynamic_cast<CMy3027View*>(pMF->GetActiveView());
                  if(pView)
                  m_numOfValues= pView->m_imageIndex;

                  You might have to turn on the RTTI option in VC.

                  R Offline
                  R Offline
                  raner
                  wrote on last edited by
                  #11

                  It ran into exception handling error while executing pView = dynamic_cast(pMF->GetActiveView()); Anyway...is there a better way to obtain member variables of a CView class then?

                  P 1 Reply Last reply
                  0
                  • R raner

                    It ran into exception handling error while executing pView = dynamic_cast(pMF->GetActiveView()); Anyway...is there a better way to obtain member variables of a CView class then?

                    P Offline
                    P Offline
                    palbano
                    wrote on last edited by
                    #12

                    good grief :mad: the code you posted is horribly wrong considering it was provided to you correctly

                    "No matter where you go, there your are..." - Buckaoo Banzi

                    -pete

                    R 1 Reply Last reply
                    0
                    • P palbano

                      good grief :mad: the code you posted is horribly wrong considering it was provided to you correctly

                      "No matter where you go, there your are..." - Buckaoo Banzi

                      -pete

                      R Offline
                      R Offline
                      raner
                      wrote on last edited by
                      #13

                      ;Poops...i mean i did run the right statement(that below) when i got an exception error. pView = dynamic_cast(pMF->GetActiveView());

                      P 1 Reply Last reply
                      0
                      • R raner

                        ;Poops...i mean i did run the right statement(that below) when i got an exception error. pView = dynamic_cast(pMF->GetActiveView());

                        P Offline
                        P Offline
                        palbano
                        wrote on last edited by
                        #14

                        oh, u missed the "display this message as-is (no HTML)" check box. sorry :-O did you turn on the RTTI build option?

                        "No matter where you go, there your are..." - Buckaoo Banzi

                        -pete

                        R 1 Reply Last reply
                        0
                        • P palbano

                          oh, u missed the "display this message as-is (no HTML)" check box. sorry :-O did you turn on the RTTI build option?

                          "No matter where you go, there your are..." - Buckaoo Banzi

                          -pete

                          R Offline
                          R Offline
                          raner
                          wrote on last edited by
                          #15

                          :-D i c i c yes i did enable it, under project->settings->c++ language...

                          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