Please help with "A required resource" error
-
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
-
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
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
-
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
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.
-
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
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);
-
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);
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()
-
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()
Yup - and you might also look at SaveDC() and RestoreDC().