将按钮形状更改为圆形,并在mfc中分为8段 [英] Change button shape to circle and divide into 8 segments in mfc

查看:317
本文介绍了将按钮形状更改为圆形,并在mfc中分为8段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将按钮形状更改为圆形并将其划分为8个区段,并使用8种颜色填充8个区段(使用颜色渐变)。目前我正在使用anglearc()函数来划分圆圈,但它无法正常工作。这很紧急。请有人发布解决方案。



我尝试过:



我尝试了角度弧和饼图函数

解决方案

它应该是8个非矩形的单个按钮。



您可以通过使用此Windows API函数来实现此类功能: SetWindowRgn函数(Windows) [ ^ ]。



这是此函数的MFC包装器:CWnd :: SetWindowRgn [ ^ ]。



当您将区域更改为窗口内的较小区域时(表示一个但是ton)边界矩形,效果不仅是视觉效果。单击从通常的矩形区域取出的矩形部分的鼠标事件将被发送到下面的窗口。



当然,在大多数情况下,你会还需要自定义绘图,或从头开始控制控件:绘画和绘图(Windows) [ ^ ]。



您可能决定从MFC派生您的控件类 CButton ,派生自 CWnd ,因此您可以使用相同的区域设置功能,或者您可以根据<$来开发按钮类c $ c> CWnd 并按照您想要的方式绘制它(参见上面引用的链接):

CButton类 [ ^ ],

CWnd Class [ ^ ]。



-SA

I want to change the button shape into circle and divide it into 8 segments and fill 8 segments with 8 colors (using color gradient). Currently i'm using anglearc() function to divide circle and it is not working properly. its urgent. Please somebody post a solution .

What I have tried:

I tried angle arc and pie function

解决方案

It should be 8 individual buttons of non-rectangular shape.

You can achieve such thing by using this Windows API function: SetWindowRgn function (Windows)[^].

This is the MFC wrapper for this function: CWnd::SetWindowRgn[^].

When you change your region to smaller region inside your Window (representing a button) bounding rectangle, the effect is not only visual. The mouse events clicked on the part of this rectangle taking out from the usual rectangular region will be dispatched to the window underneath.

Of course, in most cases, you will also need custom drawing, or pain the control from scratch: Painting and Drawing (Windows)[^].

You may decide to derive your control class from MFC CButton, which is derived from CWnd, so you can use the same region setting function, or you may develop your button class based on, say CWnd and paint it the way you want (see the link referenced above):
CButton Class[^],
CWnd Class[^].

—SA


这篇关于将按钮形状更改为圆形,并在mfc中分为8段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆