Transparent Window Sample
There's been some internal discussion about transparent and/or non-rectangular windows recently, and Nick Kramer recently addressed the issue in a blog post. Although I haven't had time to build a new solution that works with Avalon, I do have some older code that I've used to create layered windows in the past. Feel free to download the C# AlphaWindow solution for Visual Studio 2005 (the code originated in Visual Studio 2003). I don't know if this is the absolute best way to accomplish this, but it's worked for me in practice.
Basically, you have to provide a 32-bit image that includes an alpha channel (PNG). In the case of this example, the image is included as an embedded resource in the Visual Studio project. A quick look at the code should get you going. Notice that you can drag the window by clicking on any portion of the image that isn't completely transparent, including the drop shadow.
These windows work great for application splash screens where you display the window, do some start-up work, and hide it when you're done. You can also easily imagine Konfabulator-like functionality. I'd love to see someone adapt this to an Avalon sample. If you do this, share it with the rest of us in the Channel 9 Sandbox. Good luck!
Comments
Anonymous
July 07, 2005
The comment has been removedAnonymous
July 12, 2005
I am hoping that Avalon provides much better support for this stuff than the current layered window approach, btw. Layered windows have great initial promise, but then you have to jump through so many hoops to get stuff to work. And there is no way to run video or a browser control (or even a rich text control) on them because you have to provide the image for the entire window. The only way to make stuff like that work is if you use nefarious methods which aren't 100% reliable. Speaking as a current Konfabulator developer and a former Apple employee who worked on the UI Toolbox for almost 8 years, I can tell you that a lot of work needs to happen (and the current set of very bad bugs that exist in gdi+ need to be fixed) in order to truly create a good, solid platform for this kind of thing.Anonymous
July 13, 2005
Can someone point me to a sample written in plain C?? i need this really hard by now ;o)
Thx in advance, MarkusAnonymous
July 19, 2005
Recently Carl Franklin (www.dotnetrocks.com) and I created an application that takes transparent windows to the extreme. Check it out at http://shrinkster.com/4x9 and http://shrinkster.com/6so
Particularly note the translucent (Longhorn Aero Glass style) windows at the second URL.Anonymous
June 13, 2006
Hi Michael i want to thank u for this helpfull code , but i still have a question this code didnt help me to design a similar form but containd controls
can u help me to naswer this
thx again for sharing ur effortsAnonymous
September 19, 2006
Hi Michael,
You said this project started in Visual Studio 2003. I am having a rough time trying to set the build action to a item as a embedded resource in visual studio 2003. Do you still have the project in 2003, or could you explain to me how to set a item as a embedded resource in visual studio 2003. Thanks a whole lot for this project.Anonymous
December 13, 2006
Michael, I was not able to host controls on this window. Controls do not show up. Any idea why?Anonymous
May 16, 2007
i want this sample but in visual basic .net 2005 not in c# can u help meAnonymous
October 01, 2007
Is there any way to put controls on the form??Anonymous
October 01, 2007
Hello. I'am very interested in this. Is there any way to put controls on the form??Anonymous
August 18, 2008
The comment has been removed