Jump to content



Photo

_GUICtrlCreateContainer()


  • Please log in to reply
6 replies to this topic

#1 rakudave

rakudave

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 30 July 2006 - 08:03 PM

this UDF if made for controing multiple GUIControls, with one command.
the times when you had to use for-loops and arrays to disable 5 bottons at the same time are over.
one line of code and *whoosh*, all buttons are disabled...


i made this 'cause I was looking for something like this and could'nt find it...
and there is a post in the support discussing this problem ( http://www.autoitscript.com/forum/index.ph...=29267&st=0 )

(almost) all functions that are available in GUICtrlSet* are also in the UDF: _GUIContainerSet*
such as: _GUIContainerSetData, _GUIContainerSetStyle, _GUIContainerSetState, _GUIContainerSetColor and so forth


;===============================================================================
;
; Function Name: _GUICtrlCreateContainer($ctrl_1, ctrl_2, ... , ctrl_n)
; Description: Creates a container for mass GUIcontrol handling
; Parameter(s): $ctrl_1 = the first id of the container
; $ctrl_2 = the second id
; $ctrl_n = ... the n'th id (up to 255 id's supported)
; Requirement(s): none
; Return Value(s): the id of the container
; Author(s): rakudave
;
;===============================================================================


here's the UDF including an example:

Attached Files


Edited by rakudave, 31 July 2006 - 12:53 PM.






#2 WTS

WTS

    Polymath

  • Active Members
  • PipPipPipPip
  • 247 posts

Posted 30 July 2006 - 08:54 PM

cool job rakudave. i'm looking into making it support more than 255 controls right now

#3 rakudave

rakudave

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 30 July 2006 - 11:14 PM

thx
should be no prob, although it is very unlikely that anyone'll need more... ^^

#4 rakudave

rakudave

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 31 July 2006 - 12:52 PM

... or do you?

#5 Danny35d

Danny35d

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 783 posts

Posted 31 July 2006 - 12:55 PM

@rakudave I like your UDF. This is different way which allow you to set as many controls you want and have all the GUICtrlSet on one UDF.

AutoIt         
;example #include <GUIConstants.au3> Dim $container1[3] GUICreate("my gui") $a1 = GUICtrlCreateButton("asfds",5,5) $a2 = GUICtrlCreateButton("sdfg",25,25) $a3 = GUICtrlCreateButton("vcmn",45,45) $a4 = GUICtrlCreateButton("fgj",65,65) $a5 = GUICtrlCreateButton("fgj",85,85) $a6 = GUICtrlCreateButton("uir",105,105) $container1[0] = $a2 $container1[1] = $a4 $container1[2] = $a6 $container2 = StringSplit($a1 & '|' & $a3 & '|' & $a5, '|') _GUICtrlSetContainer($container2, 'GUICtrlSetState', $GUI_HIDE) GUISetState() sleep(500) _GUICtrlSetContainer($container1, 'GUICtrlSetState', $GUI_HIDE) _GUICtrlSetContainer($container2, 'GUICtrlSetState', $GUI_SHOW) sleep(500) _GUICtrlSetContainer($container1, 'GUICtrlSetState', $GUI_SHOW) _GUICtrlSetContainer($container2, 'GUICtrlSetState', $GUI_HIDE) sleep(500) ; /example #include-once ;=============================================================================== ; ; Function Name:   _GUICtrlContainer(ByRef $aCtrl, $sFunction, $Param1 = '', $Param2 = '', $Param3 = '', $Param4 = '') ; Description:     Set a container for mass GUIcontrol handling ; Parameter(s):    $aCtrl = an array with all control ID ;                  $sFunction = name of set function (guictrlsetstate, guictrlsetcolor, guictrlsetlimit, etc...) ;                  $Param1 to $Param4 = information need it for the called function ; Requirement(s):  none ; Return Value(s): an array of called function success or failure codes ; Failure(s):      return 1 if called function is not found ;                  return 2 when using GUICtrlSetStyle and $Param1 = '' ; ; Author(s):       Danny35d ; ;=============================================================================== Func _GUICtrlSetContainer(ByRef $aCtrl, $sFunction, $Param1 = '', $Param2 = '', $Param3 = '', $Param4 = '')         Local $ret = ''         Local $sFunctionNames = 'GUICtrlSetState|GUICtrlSetBkColor|GUICtrlSetColor|GUICtrlSetData|' & _             'GUICtrlSetCursor|GUICtrlSetFont|GUICtrlSetImage|GUICtrlSetLimit|GUICtrlSetStyle|GUICtrlSetTip'                 If $aCtrl[0] <> (UBound($aCtrl) - 1) Then             ReDim $aCtrl[UBound($aCtrl) + 1]             For $x = (UBound($aCtrl) - 1) To 1 Step -1                 $aCtrl[$x] = $aCtrl[$x - 1]             Next             $aCtrl[0] = UBound($aCtrl) - 1              EndIf         If StringInStr($sFunctionNames, $sFunction) == 0 Then Return(1)         $sFunction = StringLower($sFunction)         Dim $ret[$aCtrl[0] + 1]         $ret[0] = $aCtrl[0]         For $x = 1 To $aCtrl[0]             Select                      Case $sFunction = 'guictrlsetbkcolor'                 If $Param1 == '' Then $Param1 = 0x00ff00  ;Green                 $ret[$x] = GUICtrlSetBkColor($aCtrl[$x], $Param1)             Case $sFunction = 'guictrlsetcolor'                 If $Param1 == '' Then $Param1 = 0x00ff00  ;Green                 $ret[$x] = GUICtrlSetColor($aCtrl[$x], $Param1)                     Case $sFunction = 'guictrlsetcursor'                 If $Param1 == '' Then $Param1 = 2                 GUICtrlSetCursor($aCtrl[$x], $Param1)             Case $sFunction = 'guictrlsetdata'                 If $Param2 == '' Then $Param2 = -1                 $ret[$x] = GUICtrlSetData($aCtrl[$x], $Param1, $Param2)             Case $sFunction = 'guictrlsetfont'                 If $Param1 == '' Then $Param1 = 9                 If $Param2 == '' Then $Param2 = 400                 If $Param3 == '' Then $Param3 = 0                 If $Param4 == '' Then $Param4 = 'Arail'                 $ret[$x] = GUICtrlSetFont($aCtrl[$x], $Param1, $Param2, $Param3, $Param4)                       Case $sFunction = 'guictrlsetimage'                 If $Param1 == '' Then $Param1 = 'Shell32.dll'                 If $Param2 == '' Then $Param2 = -1                 If $Param3 == '' Then $Param3 = 1                 $ret[$x] = GUICtrlSetImage($aCtrl[$x], $Param1, $Param2, $Param3)             Case $sFunction = 'guictrlsetlimit'                 If $Param1 == '' Then $Param1 = $aCtrl[0]                 If $Param2 == '' Then $Param2 = 0                 $ret[$x] = GUICtrlSetLimit($aCtrl[$x], $Param1, $Param2)             Case $sFunction = 'guictrlsetstate'                 If $Param1 == '' Then $Param1 = $GUI_SHOW+$GUI_ENABLE                 $ret[$x] = GUICtrlSetState($aCtrl[$x], $Param1)             Case $sFunction = 'guictrlsetstyle'                 If $Param1 == '' Then Return(2)                 If $Param2 == '' Then $Param2 = -1                 $ret[$x] = GUICtrlSetStyle($aCtrl[$x], $Param1, $Param2)             Case $sFunction = 'guictrlsettip'                 $ret[$x] = GUICtrlSetTip($aCtrl[$x], $Param1)             EndSelect         Next         Return($ret) EndFunc

Edited by Danny35d, 31 July 2006 - 01:10 PM.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

#6 rakudave

rakudave

    Polymath

  • Active Members
  • PipPipPipPip
  • 245 posts

Posted 31 July 2006 - 04:26 PM

ah, very nice!
i read about ByRef, but couldn't make any use of it yet, thaks... :whistle:

#7 WTS

WTS

    Polymath

  • Active Members
  • PipPipPipPip
  • 247 posts

Posted 31 July 2006 - 10:31 PM

nice one, danny




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users