修改绘图控件数据.
GUICtrlSetGraphic ( 控件ID, 类型 [, par1 [, ...
par6]] )
控件ID | 由 GUICtrlCreateGraphic 函数返回的控件标识符. |
类型 | 绘图类型 : 点(dot), 线(line), 贝赛尔曲线(bezier), 矩形(rect), 椭圆(ellipse), 饼图(pie). |
par1...par6 | 参考下面的 绘图类型列表 below. |
成功: | 返回 1. |
失败: | 返回 0. |
返回 -1, 数据无效 |
绘图 | 参数 | 结果 |
---|---|---|
$GUI_GR_COLOR | 颜色 [,背景色] | 定义下一个绘图时的颜色. 当参数"背景色"等于 $GUI_GR_NOBKCOLOR, 绘图不会填充颜色(默认). 默认线条颜色为黑色. |
$GUI_GR_MOVE | x,y | 移动当前坐标点, 但不绘图. |
$GUI_GR_DOT | x,y | 画一个点(在点周围环绕小正方形), 下一绘图将从先前位置启动. |
$GUI_GR_PIXEL | x,y | 画一个图素, 下一绘图将从先前位置启动. |
$GUI_GR_LINE | x,y | 画线. |
$GUI_GR_BEZIER | x,y,x1,y1,x2,y2 | 画两个控制点之间的贝赛尔曲线. |
$GUI_GR_RECT | x,y,w,h | 画一个矩形. 当宽(w) = 高(h), 将画一个正方形. |
$GUI_GR_ELLIPSE | x,y,w,h | 画一个椭圆. 当宽(w) = 高(h), 将画一个正圆. |
$GUI_GR_PIE | x,y,r,sa,wa | 画一个饼图. r = 半径, sa = 起始角度, wa = 扫描角度. 单位为度数. |
$GUI_GR_CLOSE | 关闭当前绘图. 添加到 $GUI_GR_LINE 或 $GUI_GR_BEZIER 关闭当前画线或贝赛尔曲线. 单独使用将被忽略. |
|
$GUI_GR_REFRESH | 强制刷新动态更新后的图形. | |
$GUI_GR_HINT | 显示贝塞尔曲线/线条曲线的控制点与终点. | |
$GUI_GR_PENSIZE | n | 设定下一绘图的画笔大小. 必须在定义 $GUI_GR_COLOR(颜色) 之前接受计算. |
$GUI_GR_NOBKCOLOR | 一个虚拟背景色, 强制闭合图形不填充颜色. 仅用于画线时. |
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Global $MAXGr
= 6, $del,
$child
Global $a[$MAXGr + 1] ; 0 和
$MAXGr 项目不允许 GUICtrlDelete 函数删除结果
Example()
Func Example()
Local
$msg, $inc, $i, $del1
GUICreate("我的
Main", -1,
-1, 100,
100)
$del1
= GUICtrlCreateButton("删除",
50, 200, 50)
GUISetState()
CreateChild()
$i
= 1
$inc
= 1
;$i=5
; 去掉注释改变图形删除顺序
;$inc=-1
Do
$msg = GUIGetMsg()
If $msg = $del1 Then $i = Del($inc)
If $msg = $del Then
GUICtrlDelete($a[$i])
$i = $i + $inc
If $i < 0 Or $i > $MAXGr Then Exit
EndIf
Until
$msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Func Del($iInc)
GUIDelete($child)
CreateChild()
If
$iInc =
-1 Then Return 5
Return 1
EndFunc ;==>Del
Func CreateChild()
$child = GUICreate("我的绘图", 440, 400)
$del
= GUICtrlCreateButton("删除",
50, 165, 50)
$a[1] =
GUICtrlCreateGraphic(20,
50, 100, 100)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60,
90)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 80)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xc0c0ff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
GUICtrlCreateLabel("标记", 65, 100, 30)
GUICtrlSetColor(-1, 0xff)
$a[2] =
GUICtrlCreateGraphic(220,
10, 100, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60,
90)
$a[3] =
GUICtrlCreateGraphic(220,
110, 100, 100)
GUICtrlSetBkColor(-1, 0xf08080)
GUICtrlSetColor(-1, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_HINT, 1)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 80, 80)
$a[4] =
GUICtrlCreateGraphic(20,
200, 80, 80)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_HINT, 1)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 40)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 70, 70)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 50)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffff00)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 10)
$a[5] =
GUICtrlCreateGraphic(150,
10, 50, 50)
GUICtrlSetBkColor(-1, 0xa0ffa0)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 20, 20) ;
起点
;
最好是在点以后画线
;
避免转换每个绘图的颜色
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000ff)
GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 30)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 20, 40)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_DOT, 25, 25)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 40, 40)
GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 40)
$a[6] =
GUICtrlCreateGraphic(110,
260, 230, 130)
GUICtrlSetColor(-1, 0) ;
显示一个黑色的边界线
GUICtrlSetBkColor(-1, 0xc0c0ff)
GUICtrlSetGraphic(-1, $GUI_GR_HINT, 3) ;
显示控制线和终点
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff); fill in
blue
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 120, 20) ;
起点
GUICtrlSetGraphic(-1, $GUI_GR_BEZIER, 120, 100, 200, 20, 200, 100)
GUICtrlSetGraphic(-1, $GUI_GR_BEZIER + $GUI_GR_CLOSE, 100, 40, 40, 100, 40, 20)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 60, 30) ;
起点
GUISetState()
EndFunc ;==>CreateChild
provider with jb51.net (unicode) |