Jump to content

  • Log In with Google      Sign In   
  • Create Account


GDI & small ellipses


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Eliad Moshe   Members   -  Reputation: 797

Like
0Likes
Like

Posted 12 October 2012 - 02:57 PM

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?

tab_ex8.jpg

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

Edited by Eliad Moshe, 12 October 2012 - 03:04 PM.


Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9395

Like
3Likes
Like

Posted 12 October 2012 - 03:28 PM

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.

#3 Eliad Moshe   Members   -  Reputation: 797

Like
0Likes
Like

Posted 12 October 2012 - 04:01 PM

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, 12 October 2012 - 04:01 PM.


#4 jwezorek   Crossbones+   -  Reputation: 1620

Like
2Likes
Like

Posted 12 October 2012 - 05:50 PM

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.

#5 Eliad Moshe   Members   -  Reputation: 797

Like
0Likes
Like

Posted 12 October 2012 - 06:09 PM

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.

#6 Amr0   Members   -  Reputation: 1033

Like
1Likes
Like

Posted 13 October 2012 - 08:39 AM

[Edit: removing my post]

Edited by Amr0, 13 October 2012 - 09:00 AM.


#7 SiCrane   Moderators   -  Reputation: 9395

Like
1Likes
Like

Posted 13 October 2012 - 08:48 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS