Apologies - this is a complicated one to explain. I use a utility called AWM (www.actualtools.com) to add extra functionality to the regular Win32 windowing system. One of the things AWM can do is close / minimise / roll-up windows which aren't active. I want to use the PSM window as a kind of transient pop-up window rather than have it visible all the time. So, I created an AWM rule that would close the PSM window when it became inactive.
The problem is that when PSM launches, it opens its window, and if I then focus another window immediately, PSM crashes (its System Tray icon vanishes along with the window, and on running PSM again, I get a system.invalidoperationexception error dialog (closing this allows me to run PSM again without any errors).
I can workaround this by following a very specific procedure:
Once I've done this, I can happily let AWM close the PSM window by focussing on another app - it doesn't crash PSM now, providing I've been through the 'click the Red 'X' button' routine before PSM loses initial focus.
My guess is that there's some code behind that button click event which needs to run to avoid the crash, but which isn't triggered if PSM just receives a windows message (from AWM) to close the window.
Any thoughts gratefully appreciated!