Sign in to follow this  
Eliad Moshe

GDI & small ellipses

Recommended Posts

Eliad Moshe    862
Hi Friends,

I am crafting a win32 based Tabs custom control such as in Visual Studio or in Chrome.

I am trying to match a close button as a small circle, when the cursor hovers on top of a specific tab, using the Ellipse function.

Although, I noticed that small ellipses are drawn not smooth as I expected.

Any suggestions?

[attachment=11717:tab_ex8.jpg]

* print_screen eliminates the cursor, it is on top of the bright blue tab to the right. Edited by Eliad Moshe

Share this post


Link to post
Share on other sites
SiCrane    11839
You've got a few different options. One is to use GDI+ to render the circle. Create a graphics object from the HDC you're rendering to and use Graphics::SetSmoothingMode() to anti-alias and use Graphics::DrawEllipse() to render the circle. You can also create a temporary bitmap, draw an ellipse on that and then copy that bitmap scaled down on your window. Another option is that you can pre-render a smooth circle as an image and copy that instead of drawing drawing a circle at runtime.

Share this post


Link to post
Share on other sites
Eliad Moshe    862
Thanks SiCrane for the helpful information.

Option #2 seems to be the right path for me.

I wish Microsoft could release their IE &| VS Tabs widget and spare us the joy of reinventing the wheel.
There is a nice open source project named mCtrl that supply such control, although without a drag & drop functionality. Edited by Eliad Moshe

Share this post


Link to post
Share on other sites
jwezorek    2663
I would definitely pre-render it in Photoshop or whatever and save as a PNG with an anti-aliased edge burnt in as alpha, and then include the PNG in the project as a resource. Much easier this way -- the only thing you lose is the ability to dynamically change its size, although if you really want this you could pre-render to a number of sizes and include them all or make the resource image too large and scale down to the size that you want.

Share this post


Link to post
Share on other sites
Eliad Moshe    862
It is indeed the most comfortable path, no doubts.
Option #2 seems to be more relevant because the tabs control is part of my header only GUI API.
For my domain specific needs a fixed size should suffice.

Share this post


Link to post
Share on other sites
SiCrane    11839
If you go the DrawText() route a black circle is a Unicode code point: U+25CF ?. Not every font will have it, but you won't be limited to a single font like webdings.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this