Custom Windows?

Started by
4 comments, last by CrazyCdn 18 years, 3 months ago
I would like to make a program that has a custom shape. For example, Windows Media Player, as well as many other applications, have the ability to be a custom shape. This is what I mean by custom shape: Anyway, I would like to know how that's done. Thanks.
Advertisement
They work something like this: The window is made transparent, and the interface is drawn by blitting a number of bitmaps on to the window. The bitmaps have transparent parts, indicated by a magenta colour. These parts of the bitmap are ignored during blitting, and the parts of the window which they would cover remain transparent. All of this is controlled by some scripting language. Windows Media Player uses &#106avascript. If you want to take a look at this, open any of the files in C:\Program Files\Windows Media Player\Skins with a standard zip file viewer like WinRAR. It's all in there. Winamp functions in pretty much the same way.

A quick search on Google for "making a window transparent" turned up this little gem: Transparent Windows Support in Win 2000 and Win ME. It seems to be what you're looking for, and the test program compiles and runs under Windows XP. I'm not sure if this is the correct way to do window transparency with Windows XP; you'll probably find out with some more searching.

EDIT: If you're wondering about blitting, it's the process of taking the pixels from a source device (a bitmap or something) and moving them to a destination device (a window or something). See the function BitBlt for more info.
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Alright, thanks a lot!
See this SetWindowRgn() in MSDN. I also did a simple clock. See my signature.
Nice clock there Gan!

Enlighten, if you know you're going to ship on Windows 2000 and newer operating systems, you can utilize what is generally known as "Layered Window" (instead of window region). It provides smooth blending with the rest of windows on your desktop, so you don't get those jagged edges like you see in the WMP picture above (layered windows support per-pixel alpha blending). As most people have moved on to Windows 2000 or newer OSes, it is IMO a wiser choice than using window regions :)

I have done both approaches and found that layered windows are easier to implement. Check this link for more details on how it's done.
http://www.stromcode.com/modules.php?name=Glowdot_Tutorials&op=view&tid=1

Enjoy, gives you everything you want without horrific MFC nightmares :) Incase the other provided links don't get you going in the right direction.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement