home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 February / PCWorld_2006-02_cd.bin / software / vyzkuste / triky / triky.exe / autoit-v3-setup.exe / Examples / enumicons.au3 < prev    next >
Text File  |  2005-01-19  |  3KB  |  84 lines

  1. ;===============================================================================
  2. ;
  3. ; Description:      Show all icons in the given file
  4. ; Requirement(s):   Autoit 3.0.103+
  5. ; Author(s):        YDY (Lazycat)
  6. ;
  7. ;===============================================================================
  8.  
  9. #include <GUIConstants.au3>
  10.  
  11. ; Setting variables
  12. Global $ahIcons[30], $ahLabels[30] 
  13. Global $iStartIndex = 0, $iCntRow, $iCntCol, $iCurIndex
  14. Global $sFilename = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
  15.  
  16. ; Creating GUI and controls
  17. GUICreate("Icon Selector", 385, 435, @DesktopWidth/2 - 192,_
  18. @DesktopHeight/2 - 235, -1, $WS_EX_ACCEPTFILES)
  19. GUICtrlCreateGroup("", 5, 1, 375, 40)
  20. GUICtrlCreateGroup("", 5, 50, 375, 380)
  21. $hFile = GUICtrlCreateEdit($sFilename, 12,  15, 325, 16, $ES_READONLY, $WS_EX_STATICEDGE)
  22. GUICtrlSetCursor(-1, 2) 
  23. GUICtrlSetState(-1, $GUI_ACCEPTFILES)
  24. GUICtrlSetTip(-1, "You can drop files from shell here...")
  25. $hFileSel = GUICtrlCreateButton("...", 345,  14, 26, 18)
  26. $hPrev = GUICtrlCreateButton("Previous", 10,  45, 60, 24, $BS_FLAT)
  27. GUICtrlSetState(-1, $GUI_DISABLE)
  28. $hNext = GUICtrlCreateButton("Next", 75,  45, 60, 24, $BS_FLAT)
  29.  
  30. ; This code build two arrays of ID's of icons and labels for easily update
  31. For $iCntRow = 0 to 4
  32.     For $iCntCol = 0 to 5
  33.         $iCurIndex = $iCntRow * 6 + $iCntCol
  34.         $ahIcons[$iCurIndex] = GUICtrlCreateIcon($sFilename, $iCurIndex,_
  35.         60 * $iCntCol + 25, 70 * $iCntRow + 80)
  36.         $ahLabels[$iCurIndex] = GUICtrlCreateLabel($iCurIndex,_
  37.         60 * $iCntCol+11, 70 * $iCntRow + 115, 60, 20, $SS_CENTER)
  38.     Next
  39. Next
  40.  
  41. GUISetState()
  42.  
  43. While 1
  44.     $iMsg = GUIGetMsg()
  45.    ; Code below will check if the file is dropped (or selected)
  46.     $sCurFilename = GUICtrlRead($hFile) 
  47.     If $sCurFilename <> $sFilename Then
  48.         $iStartIndex = 0
  49.         $sFilename = $sCurFilename
  50.         _GUIUpdate()
  51.     Endif
  52.    ; Main "Select" statement that handles other events
  53.     Select
  54.         Case $iMsg = $hFileSel
  55.             $sTmpFile = FileOpenDialog("Select file:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)")
  56.             If @error Then ContinueLoop
  57.             GUICtrlSetData($hFile, $sTmpFile); GUI will be updated at next iteration
  58.         Case $iMsg = $hPrev
  59.             $iStartIndex = $iStartIndex - 30
  60.             _GUIUpdate()
  61.         Case $iMsg = $hNext
  62.             $iStartIndex = $iStartIndex + 30
  63.             _GUIUpdate()
  64.         Case $iMsg = $GUI_EVENT_CLOSE
  65.             Exit
  66.     EndSelect
  67. Wend
  68.     
  69. ; Just updates GUI icons, labels and set state of "Previous" button
  70. Func _GUIUpdate() 
  71.     For $iCntRow = 0 to 4
  72.         For $iCntCol = 0 to 5
  73.             $iCurIndex = $iCntRow * 6 + $iCntCol
  74.             GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename, $iCurIndex + $iStartIndex)
  75.             GUICtrlSetData($ahLabels[$iCurIndex], $iCurIndex + $iStartIndex)
  76.         Next
  77.     Next
  78.    ; This is because we don't want negative values
  79.     If $iStartIndex = 0 Then
  80.         GUICtrlSetState($hPrev, $GUI_DISABLE)
  81.     Else
  82.         GUICtrlSetState($hPrev, $GUI_ENABLE)
  83.     Endif        
  84. EndFunc