Solved

Displaying a dialog after CResourceException

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dog bark java program 15 131
fizzArray2 challenge 1 112
withoutTen challenge 14 140
matchUp  challenge 9 134
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 …
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…
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