Hi. I have a (dialog-based) app written in C++ with MFC. It puts up a modal dialog, which does a scan of a drive, which obviously takes a few minutes. To give feedback to the user, I have the modal dialog display a count of files processed, which increments with each file. All is fine in Win XP, but under Win 7 I get a problem with the window “freezing”. It stays frozen until the scan is complete, and then comes alive again. I’ve read online that this is because Windows 7 decides that the window isn’t responding, and over-writes it with a “dummy window”, which has the effect of stopping my file count from being updated.
So, an an attempt to prevent this, I added a PeekMessage to the modal dialog’s file handling loop, to pump any messages it found. And although that seemed to work, in that the window doesn’t freeze up any more, I seem to have replaced that problem with several different problems. Now, if I click on the main window while the modal “sub” window is doing its file scan, the Exit button on the top-right of the window turns red. If I click the window again, it gets “greyed” and the modal dialog disappears behind it – and the main window icon in the taskbar says Not Responding. But actually it is responding, because if I click the minimize button, it does minimize itself, and I then see my modal dialog updating its progress count, and all looks well. But, when the modal dialog’s process finishes, it disappears. And the taskbar now has two icons, “nested” together, which when I hover over them both show the modal dialog (neither of them say “not responding”). And – this is the real problem – when I click on them, nothing comes up. The program is now effectively dead.
I’ve come up against a couple of complications while researching this – one, it seems that MFC “modal” dialogs aren’t really modal, they’re modeless, simulated to behave like modal, and two, it seems that there is a bug in Win 7 to do with taskbar icons not working. So all in all, I’m really confused at the moment how I should make my app behave nicely in Windows 7 – can anyone help? I should emphasize that I don't want users doing anything with the main window - except possibly minimizing it - while the file scan is going on.
Sorry, I misdiagnosed this slightly. Just realized that what I thought were my "secondary" problems weren't in fact caused by my message pumping, they were there all along, but showed a bit differently. So without any message pumping, it's still possible to minimize the main window - but this time I only get one icon in the taskbar - and again when the sub dialog finishes it disappears, and the program is dead - clicking the taskbar icon doesn't bring it up.