Solved

A required resource was unavailable

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to calculate times for developing software? 8 67
fizzArray  challenge 1 83
noX challenge 17 116
Making an alias 7 95
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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