Solved

A required resource was unavailable

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 98
if loop in java 3 114
matchUp  challenge 9 72
Fibonacci challenge 11 84
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now