创建一个圆角矩形按钮

来源:互联网 发布:腾讯视频 mac 旧版本 编辑:程序博客网 时间:2024/05/21 15:04

新建一个picture用户对象:

uo_pic

picturename属性设置为按钮使用的图片


外部函数调用:
FUNCTION ulong CreateRoundRectRgn(ulong X1,ulong Y1,ulong X2,ulong Y2,ulong X3,ulong Y3) LIBRARY "gdi32.dll"

FUNCTION ulong SetWindowRgn(ulong hWnd,ulong hRgn,boolean bRedraw) LIBRARY "user32.dll"

constructor事件脚本:

ulong width1,height1,rgnh;

width1=UnitsToPixels(width,XUnitsToPixels!)+1
height1=UnitsToPixels(height,YUnitsToPixels!)+1

rgnh = CreateRoundRectRgn(7, 7, width1 - 7 , height1 - 7, 50, 50)//参数可适当调整以适应按钮的图片
SetWindowRgn(handle(this), rgnh, True)

注一:以上方法同样适用于窗口,只需要把constructor事件脚本放到窗口的open事件里就可以了。

注二:CreateRoundRectRgn函数说明

创建一个圆角矩形,该矩形由X1,Y1,X2,Y2确定,并由X3,Y3确定的椭圆描述圆角弧度
参数类型及说明
X1,Y1Long,矩形左上角的X,Y坐标
X2,Y2Long,矩形右下角的X,Y坐标
X3Long,圆角椭圆的宽。其范围从0(没有圆角)到矩形宽(全圆)
Y3Long,圆角椭圆的高。其范围从0(没有圆角)到矩形高(全圆)

原创粉丝点击