Solution for overlapping windows bug?
WPF is promising us a lot of niceties, but some of them don't live up to our expectations.
One example is the borderless window. So just this simple code added to the Xaml of the window:
AllowsTransparency="True"
Background="Transparent"
WindowStyle="None"
will make my it look nice like this: (ignore the ugly colors they got messed up during the screen clipping) alt text http://img29.imageshack.us/img29/5759/withoutborder.png
Too good to be true? Yes it is!
It looks nice, but once the user tries to select something from the ComboBox, he can't, because it opens behind !! - yes behind the window. Of course then he cannot see anything which is not very practical.
This is due to a known Windows XP bug, more here.
I was fortunate enough to be developig on an XP machine otherwise I wouldn't have found out about this until the negative feedback from my users would have hit me ... which makes me wonder, why this bug isn't mentioned anywhere, where this "great" transparent window feature is explained (e.g. books, MSDN etc.)
Even if the fix that is mentioned (link above) could work, I will not require my users to download a hotfix, just to make m开发者_如何学Goy windows look nice. That's why I'm looking for a better solution, maybe someone figured something out?
Until then my windows will have to look like this:
alt text http://img29.imageshack.us/img29/1570/withborder.png
Not very enjoyable as you can see, so you can imagine my appreciation for any solutions out there.
UPDATE:
In the meantime I confirmed, that this is only an issue when using multiple monitors (in my case Extended Desktop).
After installing the fix, the problem is gone entirely (even with extended desktop).
Downloading the fix though was a pain. Why does Microsoft make you give them your email to then send you a link to a password protected file, which then needs to be extracted manually to be able to finally install the bug fix?
Are they serious?
Shouldn't they make it simple for the users to fix Microsoft bugs? How can I tell my users (who may not be so computer inclined as we developers are) to go to some site, enter email (oh and captcha too - I guess Microsoft is afraid computers are stealing their bug fixes LOL) and then go through above described process?
Anyways, I'll stop here before the question is turned into an entirely different one which makes me emphasize that now even more I look for alternative solutions to the problem.
Yes, it is annoying when a feature like this doesn't work in an older OS and you need to support it. Here is how I would solve it:
Check the Microsoft license agreement for the hotfix download to make sure the following would be legal
Add the extracted .exe to your application (either as a separate file or inside your executable, extracted with GetManifestResourceStream, ReadAllBytes, and WriteAllBytes)
When your application starts up for the first time, check to see if you are on XP with Extended Desktop and if so, if the hotfix has been installed or you are on a newer service pack. If so, cache that fact in the registry so you can skip the check in the future.
If you are on XP with Extended Desktop and don't have the hotfix or the latest service pack, change the window background to be opaque and enable a menu option to install the hotfix.
If you are running for the first time as administrator, pop up a MessageBox saying there is a hotfix that allows window transparency and asking if you should install it. If the user says yes, run the hotfix install. If they say no, tell them the menu option is available if they change their mind in the future.
Or alternatively, if they are running on XP you could always run opaque and popup a message that your application "runs even better on Vista or Windows 7".
精彩评论