Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Displaying a dialog after CResourceException

Posted on 2001-06-22
2
Medium Priority
?
787 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

705 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