If you are using a Krypton application on Windows 7 machines then you need to be aware of a potential bug that is quite nasty. When using ShowDialog to show a window that derives from KryptonForm the window will sometimes not appear. This only seems to be the case when you have the Desktop Window Manager (DWM) enabled. It will effectively be invisible even though it has been successfully created.
For those now aware, the DWM is responsible for the Aero theme (sometimes known as the glass). Needless to say, your customers are going to be confused if a window is just plain missing. In fact your developers are going to be pretty confused as well.
The workaround for this is quite simple. You need to hook into the Shown event of the modal window and then add the following call to the PerformNeedPaint method:-
private void Form1_Shown(object sender, EventArgs e)
{
PerformNeedPaint(true);
}
I expect to release a maintenance release in about three weeks that will include this fix along with any other fixes and changes that accumulate between now and then.
August 26th, 2010 at 9:45 pm
Hi Phil,
Can you please also release the fix as code so that those like us who can’t upgrade due to project’s restriction?
I think creating a class inheriting from KryptonForm, override OnShown method and call the PerformNeedPaint if WDM is enabled will do.
August 30th, 2010 at 8:01 am
Hi Phil,
That’s great news. I’m glad you were able to track this one down. I’ve observed it occasionally for a while, but didn’t know where to start with fixing it.
September 1st, 2010 at 1:07 am
Ah, another piece of the puzzle that explains why I was getting lots of these compared to other people. Most of our applications are plugins that have to display their main window modally, otherwise they break the host application.
So pleased we’ve got a fix!
September 8th, 2010 at 4:07 am
What if the control is a User Conrtol that is been added to the main form with a docked page. In some pages we have the same bug, some part of the page is not being paint.
Thanks