Function Reference


GUICtrlSetGraphic

Modifies the data for a control.

GUICtrlSetGraphic ( controlID, type [, par1 [, ... par6]] )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreateGraphic() function.
type type of drawing : dot, line, bezier, rect, ellipse, pie.
par1...par6 See the Graphic Type table below.

Return Value

Success: 1.
Failure: 0.
-1 in case of invalid data

Remarks

The point position (x,y) is relative to the GUICtrlCreateGraphic() coordinates. It can be outside the graphic control but inside of the GUI window.

Graphic Type table

Type Parameters result
$GUI_GR_COLOR Color [,BkColor] Define the color of the next drawings. When BkColor is equal to $GUI_GR_NOBKCOLOR the drawing will not be filled. It is the default. For Color the default line color is black.
$GUI_GR_MOVE x,y Move the current position without drawing.
$GUI_GR_DOT x,y Draw a point(smallest square around the point), the next drawing will start from previous position.
$GUI_GR_PIXEL x,y Draw a pixel, the next drawing will start from previous position.
$GUI_GR_LINE x,y Draw a line.
$GUI_GR_BEZIER x,y,x1,y1,x2,y2 Draw a bezier curve with 2 control points.
$GUI_GR_RECT x,y,w,h Draw a rectangle. If w=h it will be a square.
$GUI_GR_ELLIPSE x,y,w,h Draw an ellipse. If w=h it will be a circle.
$GUI_GR_PIE x,y,r,sa,wa Draw a pie radius=r startangle=sa sweepangle=wa. Angles are in degrees.
$GUI_GR_CLOSE to close the current drawing. It has to be added to $GUI_GR_LINE or $GUI_GR_BEZIER to close current drawing. Use alone will be ignored.
$GUI_GR_REFRESH to force refresh after dynamic update of graphics.
$GUI_GR_HINT to display control point and end point of bezier/line curve.
$GUI_GR_PENSIZE n set pensize for the next drawings. It has to be defined before $GUI_GR_COLOR to be taken in account.
$GUI_GR_NOBKCOLOR is a dummy BkColor to force closed drawing not to be filled. Just line drawings.

Due to design constraints RECT, ELLIPSE and PIE graphics are drawn first. For example, a LINE will always be drawn over a RECT. If the drawing order is important to the look of the graphic, then it is recommended that multiple graphic controls be used instead of using a single control to do all the drawing.

If between several GUICtrlSetGraphic() Sleep() or other functions leading to change the Windows state GUICtrlSetGraphic( ,$GUI_GR_REFRESH) must be use to redraw the windows.

Related

GUICtrlCreateGraphic

Example

#include <GUIConstantsEx.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_idBtn_Del,$g_hChild
Example()
Func  Example()
Local $idMsg,$iInc,$i
GUICreate ("My Main",- 1,- 1,100,100)
Local $idBtn_Del1= 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= $idBtn_Del1Then $i=  Create($iInc)
If $idMsg= $g_idBtn_DelThen
GUICtrlDelete ($g_aidGraphics[$i])
$i= $i+ $iInc
If $i< 0Or $i> $g_MAXGrThen Exit
EndIf
Until $idMsg= $GUI_EVENT_CLOSE
EndFunc ;==>Example
Func  Create($iInc)
GUIDelete ($g_hChild)
  CreateChild()
If $iInc= - 1Then Return 5
Return 1
EndFunc ;==>Create
Func  CreateChild()
$g_hChild= GUICreate ("My Draw")
$g_idBtn_Del= 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

AltStyle によって変換されたページ (->オリジナル) /