R – .NET Compact Framework 3.5 animated transparent wait cursor

compact-frameworkimagenettransparency

I would like to display a "wait cursor" to the user when they have to wait for something to load. The cursor should be an animated series of bitmaps.

I can use a UserControl that I can add to a form, but the UserControl is not itself transparent.

I took the code sample available here (http://www.microsoft.com/downloads/details.aspx?FamilyId=33817CE0-B5E9-4B8E-916B-E6A381E03789&displaylang=en). While it works, I want to be able to decouple the animation from the form in a separate object. When I do that, it works for the sample app but not for my actual app.

Any suggestions? This is in .NET CF 3.5

Best Answer

What you're trying to achieve is actually pretty difficult because Windows CE doesn't support transparent windows. You can use Colorkey transparency to draw an image with transparency onto a window, but if that window overlaps yet another window (as is the case in a UserControl on top of a Form) then you'll get either a grey background, or a "hole" all the way to the desktop, depending on whether you've overriden OnPaintBackground in the UserControl.

What you have to do to get it to work is the UserControl has to actually call up to its parent and call it's OnPaint method with the bounds of your clipping region before your draw the UserControl itself.

Unfortunately I don't have a simple code example for this because where we use it we have it pretty tightly coupled to the project UI framework via a base and interface implemented in a IoC Workspace. It would take me a couple hours just to distill it to a simple example (which I intend to do for a blog entry some day, but not today).

Related Topic