Solved

A required resource was unavailable

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
format the code in java 6 116
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 601
Problem to event 3 122
ERP and the other system process verification 5 25
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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