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. Please help with "A required resource" error

Please help with "A required resource" error

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomdebuggingquestionlearning
6 Posts 3 Posters 1 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
    Joep
    wrote on last edited by
    #1

    I wrote an app which has a CScrollView derived class with several instances of an ActiveX control that I also wrote in it. Everything works fine except after a few times scrolling. Then, on Win98SE, the ActiveX controls aren't repainted anymore, the program hangs and a message box saying "A required resource was" pops up (great error message!). When I debug under Win2K it takes much longer before the program hangs and after a few seconds MSDev comes up with the disassembler window on an int 3 line. I can't find anything in the KB about "a required resource". I haven't the faintest idea where to look next. This is the last thing I must repair before rolling out the app to my clients. Does anyone have a clue what this could be? Thx a lot, Joep

    D 1 Reply Last reply
    0
    • J Joep

      I wrote an app which has a CScrollView derived class with several instances of an ActiveX control that I also wrote in it. Everything works fine except after a few times scrolling. Then, on Win98SE, the ActiveX controls aren't repainted anymore, the program hangs and a message box saying "A required resource was" pops up (great error message!). When I debug under Win2K it takes much longer before the program hangs and after a few seconds MSDev comes up with the disassembler window on an int 3 line. I can't find anything in the KB about "a required resource". I haven't the faintest idea where to look next. This is the last thing I must repair before rolling out the app to my clients. Does anyone have a clue what this could be? Thx a lot, Joep

      D Offline
      D Offline
      Dmitriy
      wrote on last edited by
      #2

      Well, the problem seems to be with GDI resources. There are a lot of info in MSDN if you search on "GDI resources". Probably you've allocated resources and never released it. But GDI resources are limited to all system - if one program will take more and more GDI resources all the running programs could be affected. This is idea

      T J 2 Replies Last reply
      0
      • D Dmitriy

        Well, the problem seems to be with GDI resources. There are a lot of info in MSDN if you search on "GDI resources". Probably you've allocated resources and never released it. But GDI resources are limited to all system - if one program will take more and more GDI resources all the running programs could be affected. This is idea

        T Offline
        T Offline
        Tim Deveaux
        wrote on last edited by
        #3

        I agree - sounds like a resource leak. Try debugging on the 98 machine - you can use the Accessories | System tools | Resource meter to view usage in more or less real time as you debug.

        1 Reply Last reply
        0
        • D Dmitriy

          Well, the problem seems to be with GDI resources. There are a lot of info in MSDN if you search on "GDI resources". Probably you've allocated resources and never released it. But GDI resources are limited to all system - if one program will take more and more GDI resources all the running programs could be affected. This is idea

          J Offline
          J Offline
          Joep
          wrote on last edited by
          #4

          I really was very sloppy in this GDI resource rich project, there were several places where I omitted to reselect an old object back into the DC. Thanks very much! But now we're talking 'bout this subject let me ask something else. Do I have to reselect the previous object each time or is once enough. In other words, should one code like this: CPen * pOldPen = pDC->SelectObject(MyPen1); ... pDC->SelectObject(pOldPen); pOldPen = pDC->SelectObject(MyPen2); ... pDC->SelectObject(pOldPen); or is this sufficient: CPen * pOldPen = pDC->SelectObject(MyPen1); ... pDC->SelectObject(MyPen2); ... pDC->SelectObject(pOldPen);

          D 1 Reply Last reply
          0
          • J Joep

            I really was very sloppy in this GDI resource rich project, there were several places where I omitted to reselect an old object back into the DC. Thanks very much! But now we're talking 'bout this subject let me ask something else. Do I have to reselect the previous object each time or is once enough. In other words, should one code like this: CPen * pOldPen = pDC->SelectObject(MyPen1); ... pDC->SelectObject(pOldPen); pOldPen = pDC->SelectObject(MyPen2); ... pDC->SelectObject(pOldPen); or is this sufficient: CPen * pOldPen = pDC->SelectObject(MyPen1); ... pDC->SelectObject(MyPen2); ... pDC->SelectObject(pOldPen);

            D Offline
            D Offline
            Dmitriy
            wrote on last edited by
            #5

            It is enough to select old object back one time on the exit in every function where you've select your GDI object: void MyFunc(CDC* pDC) { CPen * pOldPen = pDC->SelectObject(MyPen1); .. pDC->SelectObject(MyPen2); .. pDC->SelectObject(MyPen3); .. pDC->SelectObject(MyPen4); .. pDC->SelectObject(pOldPen); } Very important: don't forget to call ReleaseDC() if you've called GetDC()

            T 1 Reply Last reply
            0
            • D Dmitriy

              It is enough to select old object back one time on the exit in every function where you've select your GDI object: void MyFunc(CDC* pDC) { CPen * pOldPen = pDC->SelectObject(MyPen1); .. pDC->SelectObject(MyPen2); .. pDC->SelectObject(MyPen3); .. pDC->SelectObject(MyPen4); .. pDC->SelectObject(pOldPen); } Very important: don't forget to call ReleaseDC() if you've called GetDC()

              T Offline
              T Offline
              Tim Deveaux
              wrote on last edited by
              #6

              Yup - and you might also look at SaveDC() and RestoreDC().

              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