Solved

Displaying a dialog after CResourceException

Posted on 2001-06-22
2
773 Views
Last Modified: 2013-11-20
When my app receives a CResourceException or CMemoryException, I'd like to display a dialog telling my user that that's the reason I'm about to exit on him.

I plan to pre-allocate the dialog, and I'm catching the exception fine (in my override of CWinApp::ProcessWndProcException()).  But can I assure that my dialog will show when I call DoModal()?  It seems that will try to use a few more resources above and beyond what was preallocated.  Can I free up some pre-allocated memory for use just by my app or my pre-allocated dialog?

I realize this solution may just be for the CMemoryException and not the CResourceException, but that's alright.

thanks for any pointers or code,
bruce
0
Comment
Question by:bwdean
[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 2

Accepted Solution

by:
Slordak earned 100 total points
ID: 6235435
I would suspect that it depends on how the heap is being managed (and whether one is using the debug or release heaps, for example).

The first thing to determine would be how much heap memory is being used to create your modal dialog, and if there are any other resources (handles, tokens, semaphores, etc.) that might potentially be exhausted as well.  Assuming the only thing your dialog needs is additional heap memory, one possibility would be to allocate this much memory via a malloc/new call at the beginning of your program, then release this memory just prior to creating your dialog, assuming the heap is going to let you immediately re-use the memory and is not saving it for later garbage collection or for memory auditing purposes.  This is probably not ideal, but its hard to anticipate every possible error conditio, after all.

You'd probably also want to muck with some of the dialog settings.  I.e. Make your critical error dialog resource non-discardable while the other dialogs can be marked discardable, thereby attempting to guarantee that the dialog you need will be available in low-resource conditions.
0
 

Author Comment

by:bwdean
ID: 6410225
And two months later, I get around to responding....Thanks for the input..already what I was basically doing, but the dialog settings suggestions are good info.

thanks!
bruce
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

623 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