# Function Reference

# GUICtrlCreateGraphic

Creates a Graphic control for the GUI.

GUICtrlCreateGraphic ( left, top [, width [, height [, style]]] )

## Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $SS_NOTIFY.

## Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

## Remarks

To draw in the control see GUICtrlSetGraphic().
The border and background color can be set with GUICtrlSetBkColor() and GUICtrlSetColor().
Graphic control can be clicked so they should not overlap with other controls. If overlap is needed it is important to disable the graphic control : GUICtrlSetState(-1, $GUI_DISABLE).
This control cannot be resized due to fix graphic relative addressing creation but can be dock with GUICtrlSetResizing().

## Related

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

## Example

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

    Global Const $g_MAXGr = 6
    Global $g_a_idGrc_Array[$g_MAXGr + 1] ; 0 and $g_MAXGr entries not used to allow GUICtrlDelete result
    Global $g_idBtn_Del

    Example()

    Func Example()
        Local $idMsg, $iInc, $i

        CreateChild()

        $i = 1
        $iInc = 1
        ; Loop until the user exits.
        Do
            $idMsg = GUIGetMsg()

            If $idMsg = $g_idBtn_Del Then
                GUICtrlDelete($g_a_idGrc_Array[$i])
                $i = $i + $iInc
                If $i < 0 Or $i > $g_MAXGr Then Exit
            EndIf
            If $idMsg > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg & @CRLF & $g_a_idGrc_Array[5], 2)
        Until $idMsg = $GUI_EVENT_CLOSE
    EndFunc   ;==>Example

    Func CreateChild()
        GUICreate("My Draw")
        $g_idBtn_Del = GUICtrlCreateButton("Delete", 50, 165, 50)

        $g_a_idGrc_Array[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_a_idGrc_Array[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)

        $g_a_idGrc_Array[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)

        $g_a_idGrc_Array[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)

        $g_a_idGrc_Array[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(@SW_SHOW)
    EndFunc   ;==>CreateChild