函数参考


GUICtrlCreateGraphic

在GUI上创建一个绘图(Graphic)控件.

GUICtrlCreateGraphic ( 左侧, 顶部[, 宽度[, 高度[, 样式]]] )

参数

左侧 控件左侧的位置.若此值为 -1 则根据 GUICoordMode 的设置来计算左侧位置.
顶部 控件上方的位置.若此值为 -1 则根据 GUICoordMode 的设置来计算上方位置.
宽度 [可选参数] 控件的宽度(默认值为上一个控件的宽度).
高度 [可选参数] 控件的高度(默认值为上一个控件的高度).
 样式 [可选参数]定义控件的样式. 请参考 GUI 控件样式参考 .

默认( -1) : $SS_NOTIFY.

返回值

成功: 返回控件标识符(控件ID).
失败: 返回 0.

注意/说明

要在控件中绘图,请参考 GUICtrlSetGraphic.

边框或者背景颜色可以用 GUICtrlSetBkColor 和 GUICtrlSetColor 进行设置.

绘图控件不能接受点击事件,因此不能与其它控件交迭使用. 如果是交迭的,请关闭绘图控件 : GuiCtrlSetState(-1,$GUI_DISABLE).

使用适当的相对定址固定图形控件,控件不能调整大小,除非使用 GUICtrlSetResizing().

相关

GUICtrlSetGraphic, GUICtrlSetBkColor, GUICtrlSetColor, GUICtrlDelete, GUICoordMode (Option), GUISetState, GUICtrlSetStyle, GUICtrlSetResizing, GUIGetMsg

示例/演示


#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Global $MAXGr = 6, $del
Global $a[$MAXGr + 1] ; 0 and $MAXGr entries not used to allow GUICtrlDelete result

Example()

Func Example()
    Local $msg, $inc, $i

    CreateChild()

    $i = 1
    $inc = 1
    Do
        $msg = GUIGetMsg()

        If $msg = $del Then
            GUICtrlDelete($a[$i])
            $i = $i + $inc
            If $i < 0 Or $i > $MAXGr Then Exit
        EndIf
        If $msg > 0 Then MsgBox(0, "clicked", $msg & @LF & $a[5], 2)
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Func CreateChild()
    GUICreate("My Draw")
    $del = GUICtrlCreateButton("Delete", 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("label", 65, 100, 30)
    GUICtrlSetColor(-1, 0xff)


    $a[2] = GUICtrlCreateGraphic(220, 50, 100, 100)
    GUICtrlSetStyle(-1, $SS_NOTIFY)
    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, 150, 100, 100, 0)
    GUICtrlSetBkColor(-1, 0xf08080)
    GUICtrlSetColor(-1, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 80, 80)

    $a[4] = GUICtrlCreateGraphic(20, 200, 80, 80)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetBkColor(-1, 0xffffff)
    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, 0)
    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, 40, 40)

    GUISetState()
EndFunc   ;==>CreateChild