Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just created a round button by making it the button as owner draw and need to give effect on that button , now it appears not like a button button but like a simple round figure
Posted

You need to call Windows API SetWindowRgn. Not only it will create rounded visible region, but all functionality of the Windowed control will be limited to the region, importantly — the mouse events. Naturally, the region can be of any shape, not just rounded but defined by a combination of theory-set operations on the primitive point sets such as ellipse, rectangle, etc.

See:
http://msdn.microsoft.com/en-us/library/dd145102(v=vs.85).aspx[^].

—SA
 
Share this answer
 
Comments
Joan M 2-May-11 5:04am    
As always it is 100% correct, my 5.
Sergey Alexandrovich Kryukov 2-May-11 5:49am    
Thank you, Joan.
--SA
CPallini 2-May-11 6:02am    
Very good. 5+!
Sergey Alexandrovich Kryukov 2-May-11 6:35am    
Thank you very much.
--SA
What SAKryukov says is 100%, just in order to extend it a little, you can take a look at all the articles here[^] in CP in which some users have posted different ways to do specially shaped buttons...

PS: remember to filter by MFC ;)

HTH! :thumbsup:
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 2-May-11 5:52am    
Joan, I hope many references are useful (I used to find some good ones there), so my 5.

I only want to warn OP that those methods not using SetWindowRgn are not correct, as they would create some false positive events such as Button click event (it the user clicks at the corner, in case of rounding).

So, be careful.
--SA
Joan M 2-May-11 6:46am    
Again, you are right, I've posted those links in order to help him in solving the GUI problem and to get some pointers and easiness in having the job done, but of course if he is rounding buttons, your answer must be taken into account... ;)
Sergey Alexandrovich Kryukov 2-May-11 7:17am    
Agreed...
--SA
There are a lot of articles[^], here at CodeProject, about round buttons.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-May-11 5:53am    
Same to you. My 5, but OP should be careful by the reasons I explained in my comment to the answer by Joan.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900