Solved

A required resource was unavailable

Posted on 1998-03-11
2
1,721 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
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 102
Shell script to login to remote m/c and execute commands 10 78
sum67 challenge 35 114
Excel file not created as expected 7 90
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

680 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