11
votes

I am creating a window program using VC++ through win32 API. I wanted to create a ellipse shaped window how this can be achived.

4

4 Answers

7
votes

Using WS_EX_LAYERED in your windows style attribute, and calling UpdateLayeredWindow is probably the most flexible way to control a custom shaped / transparent window using the Win32 API. There's an excellent break down (though a little old) over on MSDN: http://msdn.microsoft.com/en-us/library/ms997507.aspx

And official doc for UpdateLayeredWindow: http://msdn.microsoft.com/en-us/library/ms633556(VS.85).aspx

1
votes

Use SetWindowRgn to make the drawing area of the window an elliptical region. This prevents drawing to the window the exceed the boundary of the ellipse.

1
votes

The only trouble with using SetWindowRgn is regions is they are difficult to create completely arbitrary shapes.

Windows 2000 introduced layered windows to solve this and is how clippy was able to escape the confines of his window.

See http://msdn.microsoft.com/en-us/library/ms997507.aspx for information regarding layered windows.

1
votes

well, this is so late reply but I thought it would be important for you to know. There is a freeware generates source code for VB, C++, C# and Delphi.All you have to do is design your form in photoshop or whatever painter, let that software detect the shape you designed and generate a code for you. You can study that code or just use it. Don't forget to read the help coz there are some issues concerning compiling. Happy Shaping. http://www.byalexv.co.uk/