GUICtrlSetGraphic
修改图形控件数据.
GUICtrlSetGraphic ( controlID, type [, par1 [, ... par6]] )
参数
controlID
|
使用 GUICtrlCreateGraphic() 函数返回的控件标识符.
|
type
|
绘图类型 : 点(dot), 线(line), 贝赛尔曲线(bezier), 矩形(rect), 椭圆(ellipse), 饼图(pie).
|
par1...par6
|
参考下面的 绘图类型列表.
|
返回值
成功:
|
返回 1.
|
失败:
|
返回 0.
返回 -1, 数据无效
|
备注
点坐标 (x,y) 是 GUICtrlCreateGraphic() 绘图控件的相对坐标. 可以超出绘图控件,但不能超出 GUI 窗口.
绘图类型列表
类型
|
参数
|
结果
|
$GUI_GR_COLOR
|
Color [,BkColor]
|
定义下一个绘图时的颜色.
当参数"背景色"等于 $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
|
|
一个虚拟背景色, 强制闭合图形不填充颜色. 仅用于画线时.
|
由于设计上的限制, 矩形, 椭圆和饼图需首先画图形控件. 例如, 一个矩形总是先画线.
如果绘制顺序对绘图外观非常重要, 则建议使用多个图形控件, 而不是使用一个单一的控件完成所有的绘图
相关
GUICtrlCreateGraphic
函数示例
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Global Const $g_MAXGr = 6
Global $g_aidGraphics[$g_MAXGr + 1] ; 0 and $g_MAXGr entries not used to allow GUICtrlDelete result
Global $g_idDel, $g_hChild
Example()
Func Example()
Local $idMsg, $iInc, $i
GUICreate("My Main", -1, -1, 100, 100)
Local $idDel1 = GUICtrlCreateButton("ReCreate", 50, 200, 50)
GUISetState(@SW_SHOW)
CreateChild()
$i = 1
$iInc = 1
;$i=5 ; uncomment to delete starting from last define Graphic control
;$iInc=-1
Do
$idMsg = GUIGetMsg()
If $idMsg = $idDel1 Then $i = Create($iInc)
If $idMsg = $g_idDel Then
GUICtrlDelete($g_aidGraphics[$i])
$i = $i + $iInc
If $i < 0 Or $i > $g_MAXGr Then Exit
EndIf
Until $idMsg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Func Create($iInc)
GUIDelete($g_hChild)
CreateChild()
If $iInc = -1 Then Return 5
Return 1
EndFunc ;==>Create
Func CreateChild()
$g_hChild = GUICreate("My Draw")
$g_idDel = GUICtrlCreateButton("Delete", 50, 165, 50)
$g_aidGraphics[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("label", 65, 100, 30)
GUICtrlSetColor(-1, 0xff)
$g_aidGraphics[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)
$g_aidGraphics[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)
$g_aidGraphics[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)
$g_aidGraphics[5] = GUICtrlCreateGraphic(150, 10, 50, 50)
GUICtrlSetBkColor(-1, 0xa0ffa0)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 20, 20) ; start point
; it is better to draw line and after point
; to avoid to switch color at each drawing
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)
$g_aidGraphics[6] = GUICtrlCreateGraphic(110, 260, 230, 130)
GUICtrlSetColor(-1, 0) ; to display a black border line
GUICtrlSetBkColor(-1, 0xc0c0ff)
GUICtrlSetGraphic(-1, $GUI_GR_HINT, 3) ; to display control lines and end points
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff); fill in blue
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 120, 20) ; start point
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) ; start point
GUISetState(@SW_SHOW)
EndFunc ;==>CreateChild
----------------------------------------
|