GDI & small ellipses

Started by
5 comments, last by SiCrane 11 years, 6 months ago
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.
Advertisement
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.
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.
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.
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.
[Edit: removing my post]
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.

This topic is closed to new replies.

Advertisement