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. What does this error mean?

What does this error mean?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiondebugging
4 Posts 2 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.
  • J Offline
    J Offline
    John Cruz
    wrote on last edited by
    #1

    I am trying to debug my program because while running my driver program i encounter a bug and the error that the computer tells me is this: " Unhandled Exception in Tictactoe.exe: 0x000005: Access violation" this error occurred in my destructor for my CBoard Class CBoard::~CBoard() { delete mpDefaultPen; <-- what is causing a exception to be thrown? } oh i used this pointer in my function // Changes the Line color to the value entered void CBoard::SetLineColor(CDC* pDC, COLORREF color) { // Sets color to mLine color mLineColor= color; // Construct a pen mpPen = new CPen; VERIFY(mpPen); VERIFY(mpPen->CreatePen(PS_SOLID,5,mLineColor)); VERIFY(mpDefaultPen = pDC->SelectObject(mpPen)); <-- rite here } Does anyone know whats causing this bug to occur? anyways... thank you in advance for helping me... i very much appreciate all the help ;) :) :)

    J 1 Reply Last reply
    0
    • J John Cruz

      I am trying to debug my program because while running my driver program i encounter a bug and the error that the computer tells me is this: " Unhandled Exception in Tictactoe.exe: 0x000005: Access violation" this error occurred in my destructor for my CBoard Class CBoard::~CBoard() { delete mpDefaultPen; <-- what is causing a exception to be thrown? } oh i used this pointer in my function // Changes the Line color to the value entered void CBoard::SetLineColor(CDC* pDC, COLORREF color) { // Sets color to mLine color mLineColor= color; // Construct a pen mpPen = new CPen; VERIFY(mpPen); VERIFY(mpPen->CreatePen(PS_SOLID,5,mLineColor)); VERIFY(mpDefaultPen = pDC->SelectObject(mpPen)); <-- rite here } Does anyone know whats causing this bug to occur? anyways... thank you in advance for helping me... i very much appreciate all the help ;) :) :)

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      You shouldn't delete mpDefaultPen, but rather select it back to pDC with SelectObject once you're done with the DC object. Check your documentation for SelectObject. The general scheme is as follows:

      mpDefaultPen =pDC->SelectObject(mpPen);
      // drawing stuff, whatever
      pDC->SelectObject(mpDefaultPen); // done with pDC, revert to original state

      Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      J 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        You shouldn't delete mpDefaultPen, but rather select it back to pDC with SelectObject once you're done with the DC object. Check your documentation for SelectObject. The general scheme is as follows:

        mpDefaultPen =pDC->SelectObject(mpPen);
        // drawing stuff, whatever
        pDC->SelectObject(mpDefaultPen); // done with pDC, revert to original state

        Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        J Offline
        J Offline
        John Cruz
        wrote on last edited by
        #3

        oh ok thank you Joaquin for the help. i forgot, i didnt create mpDefaultPen so i shouldnt delete it or it will cause me an error (i forgot what kind of error that is -- i think its the dangling pointer problem). again thank you for your help :) muchas gracias para me ayudarle :) is what is said right?? :) :) :)

        J 1 Reply Last reply
        0
        • J John Cruz

          oh ok thank you Joaquin for the help. i forgot, i didnt create mpDefaultPen so i shouldnt delete it or it will cause me an error (i forgot what kind of error that is -- i think its the dangling pointer problem). again thank you for your help :) muchas gracias para me ayudarle :) is what is said right?? :) :) :)

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          muchas gracias para me ayudarle :) is what is said right?? It's close. The correct sentence would be "Muchas gracias por ayudarme". You are welcome. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          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