Solved

A required resource was unavailable

Posted on 1998-03-11
2
1,759 Views
Last Modified: 2013-11-20
I am receiving this error when I use my scrollbar in the formview of my application.  There does not appear to be a pattern to produce the error except that it occurs when you attempt to scroll quickly.  Am I attempting to scroll too fast or what?  Any suggestion would be appreciated.

zeekial@osler.card.bgsm.edu
0
Comment
Question by:zeekial
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1316911
I would look into your window's code for handling WM_HSCROLL or WM_VSCROLL. Another possibility would be to look at WM_PAINT. There are many of these messages that will be generated whenever you scroll.

In the code, I would look for resource leaks. The most likely being GDI leaks. Remember that when you select something into a DC, save the return value from SelectObject and select that back into the DC when you're done. Otherwise, you will get leaks.


0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1316912
The "A required resource was not found" message corresponds to the AFX_IDS_RESOURCE_EXCEPTION string resource provided by MFC. This string is presented in a message box by MFC when someone calls the ReportError() member on a CResourceException object.  A CResourceException is thrown whenever a resource-based function is called in MFC and fails.  For example, if you try to create a CPen in the constructor and the creation fails, you'll get the exception.

You should bracket calls that throw exceptions in your code with try/catch. There's lots of books and code samples that show how to do this properly. When you do it properly, you can react to critical error conditions in a sane way.

If you don't set up a try/catch handler and an exception is thrown, MFC's backstop try/catch handler will step in to prevent your application from crashing or abnormially terminating. MFC's default handler simply calls ReportError() on whatever exception was raised and leaves it at that.

I think your problem is that you're ignoring exceptions in error conditions, not that you're leaking resources. If you put a breakpoint on the CResourceException constructor, or on the AfxThrowResourceException() function, you should find out why it's called in short order. But the real fix is to catch and handle exceptions that your code might generate.

.B ekiM

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question