Creates an Icon control for the GUI.
GUICtrlCreateIcon ( filename, iconName, left, top [, width [, height [, style [, exStyle]]]] )
Parameters
| filename | filename of the icon to be loaded. |
| iconName | Icon name if the file contain multiple icon. Can be an ordinal name if negative number. Otherwise -1. |
| 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 32). |
| height | [optional] The height of the control (default is 32). |
| style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $SS_NOTIFY forced styles : $WS_TABSTOP, $SS_ICON |
| exStyle | [optional] Defines the extended style of the control. See Extended Style Table. |
Return Value
| Success: | Returns the identifier (controlID) of the new control. |
| Failure: | Returns 0. |
Remarks
To set or change information in the control see GUICtrlSet....
Related
GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg
Example
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example1()
Example2()
;example1 ---------------------------
Func Example1()
Local $icon, $n1, $n2, $msg
GUICreate(" My GUI Icons", 250, 250)
$icon = GUICtrlCreateIcon("shell32.dll", 10, 20, 20)
$n1 = GUICtrlCreateIcon(@WindowsDir & "\cursors\horse.ani", -1, 20, 40, 32, 32)
$n2 = GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
EndFunc ;==>Example1
; example2 ---------------------------
Func Example2()
Local $iOldOpt, $n1, $n2, $a, $b
$iOldOpt = Opt("GUICoordMode", 1)
GUICreate("My GUI icon Race", 350, 74, -1, -1)
GUICtrlCreateLabel("", 331, 0, 1, 74, 5)
$n1 = GUICtrlCreateIcon(@WindowsDir & "\cursors\dinosaur.ani", -1, 0, 0, 32, 32)
$n2 = GUICtrlCreateIcon(@WindowsDir & "\cursors\horse.ani", -1, 0, 40, 32, 32)
GUISetState(@SW_SHOW)
Dim $a = 0, $b = 0
While ($a < 300) And ($b < 300)
$a = $a + Int(Random(0, 1) + 0.5)
$b = $b + Int(Random(0, 1) + 0.5)
GUICtrlSetPos($n1, $a, 0)
GUICtrlSetPos($n2, $b, 40)
Sleep(20)
WEnd
Sleep(1000)
Opt("GUICoordMode", $iOldOpt)
EndFunc ;==>Example2