0
votes

Environment: MFC frame based SDI application Problem: After closing modal dialog boxes, the bitmap stays displayed/the window beneath doesn't repaint.

Dialog creation:

PortSettings Dlg; 
Dlg.DoModal();

I've tried explicitly setting OnCancel() for the dialog class,

void PortSettings::OnCancel()
{CDialog::OnCancel();}

tried calling RedrawWindow from the parent window and the Dialog OnCancel.

This issue happens for all the dialog boxes, and other modal windows that open (Like a file browser) I assume because I am using MFC I've somehow interfered with the underlying Window Proc but I'm not sure how to investigate or what to try.

1
It seems that you have some issues in your SDI view. I would go and check OnDraw() and OnEraseBkgnd().Andrew Komiagin
Thank you Andrew! I haven't modified OnDraw, should I be?? I don't see OnEraseBkgnd specfically in the MFC code. Should I add it?V J
Forcing Redraw after each dialog closes repaints the controls and bitmaps, however the ghost images still linger in the background. Where should I add an OnEraseBkgnd call?V J
onDraw is where you normally draw your window. If you haven't modified it, how exactly are you drawing something in the window? At first blush, it sounds like you don't quite understand how MFC (and Windows in general) handles drawing. As a point of reference, I don't think I've ever written a call to RedrawWindow in any MFC code. I've done a lot of calls to Invalidate(), which indirectly causes a redraw--but I've never had to do that for redrawing after a dialog was dismissed--in that case, it's automatic.Jerry Coffin
Thank you Jerry - you are right, this is my first application. I am drawing in OnPaint(). Any advice, references, etc would be appreciated. I use MSDN as much as possible but it is very detail oriented.V J

1 Answers

0
votes

Solution was multifaceted:

Dialog Window Properties affect the image lingering - in my case, it was necessary to change the dialog frame to "thin" style.

After the Dlg.DoModal() call, call ParentWnd->RedrawWindow(). In the Parent Window's OnPaint, I added a fillSolidRect to repaint the background white. This section is controlled with Boolean logic to only repaint immediately after a dialog closes to avoid flickering.