Problem with TransparencyKey in Windows Forms C#
I'm trying to have in .NET 2.0 a transparent form, that is on top, invisible for mouse clicks but is possible to draw on it. I can easily reach开发者_高级运维 this by setting the TransparencyKey to background color of the form. But there is one very easy to reproduce problem in all java programs (e.g. JDownloader, Vuze, Open Office): sometime when context menu is shown it leaves the part of (or whole) menu still visible after I click somewhere else. It is physically closed because it is unable to click on any item, but the image of it stays on my top invisible form - probably there was some problem in redrawing. I be very grateful for any help.
Hugo
A normal Windows application implements context menus as real windows, so when they're dismissed by the user all the windows underneath properly receive notification and repaint themselves, so the image of the menu isn't "left behind" anywhere.
The java apps you're having problems with most likely implement context menus by drawing directly on the screen, and when the menus are dismissed the app rolls-its-own and invalidates all the windows underneath it. I'm guessing that this method doesn't invalidate the region occupied by your app because it thinks your window is above it and it doesn't realize your app is transparent (this is speculation - I don't know for sure. if the context menus for these apps look different than the menus for a native app, then this is probably what's going on).
If this is what's happening, there's not much you can do about it. One thing you could do is draw to the screen yourself, instead of using a transparent window. Or you could just have a timer on your form periodically call refresh/invalidate.
精彩评论