Solved

Displaying a dialog after CResourceException

Posted on 2001-06-22
2
752 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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