Jump to content

Icon Selector?


DeeRiee
 Share

Recommended Posts

Can somebody make icon selector?

I'm trying to modify this script from help file, but i still can't.

So, I need your help please :)

This is the script that I'm trying to edit:

;===============================================================================
;
; Description:      Show all icons in the given file
; Requirement(s):   Autoit 3.0.103+
; Author(s):        YDY (Lazycat)
;
;===============================================================================

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)

; Setting variables
Global $ahIcons[30], $ahLabels[30]
Global $iStartIndex = 1, $iCntRow, $iCntCol, $iCurIndex
Global $sFilename = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $iOrdinal = -1

Global $hPrev

_Main()

Func _Main()
    Local $hGui, $hFile, $hFileSel, $hNext, $hToggle
    Local $iMsg, $sCurFilename, $sTmpFile

    ; Creating GUI and controls
    $hGui = GUICreate("Icon Selector by Ordinal value", 385, 435, @DesktopWidth / 2 - 192, _
            @DesktopHeight / 2 - 235, -1, $WS_EX_ACCEPTFILES)
    GUICtrlCreateGroup("", 5, 1, 375, 40)
    GUICtrlCreateGroup("", 5, 50, 375, 380)
    $hFile = GUICtrlCreateInput($sFilename, 12, 15, 325, 16, -1, $WS_EX_STATICEDGE)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetTip(-1, "You can drop files from shell here...")
    $hFileSel = GUICtrlCreateButton("...", 345, 14, 26, 18)
    $hPrev = GUICtrlCreateButton("Previous", 10, 45, 60, 24, $BS_FLAT)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $hNext = GUICtrlCreateButton("Next", 75, 45, 60, 24, $BS_FLAT)
    $hToggle = GUICtrlCreateButton("by Name", 300, 45, 60, 24, $BS_FLAT)

    ; This code build two arrays of ID's of icons and labels for easily update
    For $iCntRow = 0 To 4
        For $iCntCol = 0 To 5
            $iCurIndex = $iCntRow * 6 + $iCntCol
            $ahIcons[$iCurIndex] = GUICtrlCreateIcon($sFilename, $iOrdinal * ($iCurIndex + 1), _
                    60 * $iCntCol + 25, 70 * $iCntRow + 80)
            $ahLabels[$iCurIndex] = GUICtrlCreateLabel($iOrdinal * ($iCurIndex + 1), _
                    60 * $iCntCol + 11, 70 * $iCntRow + 115, 60, 20, $SS_CENTER)
        Next
    Next

    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        ; Code below will check if the file is dropped (or selected)
        $sCurFilename = GUICtrlRead($hFile)
        If $sCurFilename <> $sFilename Then
            $iStartIndex = 1
            $sFilename = $sCurFilename
            _GUIUpdate()
        EndIf
        ; Main "Select" statement that handles other events
        Select
            Case $iMsg = $hFileSel
                $sTmpFile = FileOpenDialog("Select file:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)")
                If @error Then ContinueLoop
                GUICtrlSetData($hFile, $sTmpFile); GUI will be updated at next iteration
            Case $iMsg = $hPrev
                $iStartIndex = $iStartIndex - 30
                _GUIUpdate()
            Case $iMsg = $hNext
                $iStartIndex = $iStartIndex + 30
                _GUIUpdate()
            Case $iMsg = $hToggle
                If $iOrdinal = -1 Then
                    $iOrdinal = 1
                    GUICtrlSetData($hToggle, "by Ordinal")
                    WinSetTitle($hGui, "", "Icon Selector by Name value")
                Else
                    $iOrdinal = -1
                    GUICtrlSetData($hToggle, "by Name")
                    WinSetTitle($hGui, "", "Icon Selector by Ordinal value")
                EndIf
                _GUIUpdate()
            Case $iMsg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
    WEnd
EndFunc   ;==>_Main

; Just updates GUI icons, labels and set state of "Previous" button
Func _GUIUpdate()
    For $iCntRow = 0 To 4
        For $iCntCol = 0 To 5
            $iCurIndex = $iCntRow * 6 + $iCntCol
            GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename, $iOrdinal * ($iCurIndex + $iStartIndex))
            If $iOrdinal = -1 Then
                GUICtrlSetData($ahLabels[$iCurIndex], -($iCurIndex + $iStartIndex))
            Else
                GUICtrlSetData($ahLabels[$iCurIndex], '"' & ($iCurIndex + $iStartIndex) & '"')
            EndIf
        Next
    Next
    ; This is because we don't want negative values
    If $iStartIndex = 1 Then
        GUICtrlSetState($hPrev, $GUI_DISABLE)
    Else
        GUICtrlSetState($hPrev, $GUI_ENABLE)
    EndIf
EndFunc   ;==>_GUIUpdate

Please give that script GuiCtrlCreateRadio on every icon it show...

Sorry bad english... >_<

Link to comment
Share on other sites

Here's a stab at it...

Just click the label # under the icon

;===============================================================================
;
; Description:      Show all icons in the given file
; Requirement(s):   Autoit 3.0.103+
; Author(s):        YDY (Lazycat)
;
;===============================================================================

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>

Opt('MustDeclareVars', 1)

; Setting variables
Global $ahIcons[35], $ahLabels[35]
Global $iStartIndex = 1, $iCntRow, $iCntCol, $iCurIndex
Global $sFilename = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $iOrdinal = -1

Global $hPrev

_Main()

Func _Main()
    Local $hGui, $hFile, $hFileSel, $hNext, $hToggle
    Local $iMsg, $sCurFilename, $sTmpFile
    Local $aMsg, $Icon_List, $Icon_num, $temp_GUI

    ; Creating GUI and controls
    $hGui = GUICreate("Icon Selector by Ordinal value", 385, 435, @DesktopWidth / 2 - 192, _
            @DesktopHeight / 2 - 235, -1, $WS_EX_ACCEPTFILES)
    GUICtrlCreateGroup("", 5, 1, 375, 40)
    GUICtrlCreateGroup("", 5, 50, 375, 380)
    $hFile = GUICtrlCreateInput($sFilename, 12, 15, 325, 16, -1, $WS_EX_STATICEDGE)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetTip(-1, "You can drop files from shell here...")
    $hFileSel = GUICtrlCreateButton("...", 345, 14, 26, 18)
    $hPrev = GUICtrlCreateButton("Previous", 10, 45, 60, 24, $BS_FLAT)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $hNext = GUICtrlCreateButton("Next", 75, 45, 60, 24, $BS_FLAT)
    $hToggle = GUICtrlCreateButton("by Name", 300, 45, 60, 24, $BS_FLAT)

    ; This code build two arrays of ID's of icons and labels for easily update
    For $iCntRow = 0 To 4
        For $iCntCol = 0 To 5
            $iCurIndex = $iCntRow * 6 + $iCntCol
            $ahIcons[$iCurIndex] = GUICtrlCreateIcon($sFilename, $iOrdinal * ($iCurIndex + 1), _
                    60 * $iCntCol + 25, 70 * $iCntRow + 80)
            $ahLabels[$iCurIndex] = GUICtrlCreateLabel($iOrdinal * ($iCurIndex + 1), _
                    60 * $iCntCol + 11, 70 * $iCntRow + 115, 60, 20, $SS_CENTER)
        Next
    Next

    GUISetState()

    While 1
; ************************************* ADD *********************
        $aMsg = GUIGetCursorInfo($hGui)
        If $aMsg[2] = 1 And _ArraySearch($ahLabels, $aMsg[4]) <> -1 Then
            $Icon_List = GUICtrlRead($hFile)
            $Icon_num = Int(GUICtrlRead($aMsg[4]))
            ; do what you want here
            $temp_GUI = GUICreate("Icon", 350, 300)
            GUICtrlCreateLabel("From " & $Icon_List, 20, 20, 250, 20)
            GUICtrlCreateLabel("You chose Icon #" & $Icon_num, 20, 60, 250, 20)
            GUICtrlCreateIcon($sFilename, $Icon_num, 60, 100, 40, 40)
            GUISetState()
            Sleep(3000)
            GUIDelete($temp_GUI)
        EndIf
; *********************************** END ADD **********************


        $iMsg = GUIGetMsg()
        ; Code below will check if the file is dropped (or selected)
        $sCurFilename = GUICtrlRead($hFile)
        If $sCurFilename <> $sFilename Then
            $iStartIndex = 1
            $sFilename = $sCurFilename
            _GUIUpdate()
        EndIf
        ; Main "Select" statement that handles other events
        Select
            Case $iMsg = $hFileSel
                $sTmpFile = FileOpenDialog("Select file:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)")
                If @error Then ContinueLoop
                GUICtrlSetData($hFile, $sTmpFile); GUI will be updated at next iteration
            Case $iMsg = $hPrev
                $iStartIndex = $iStartIndex - 30
                _GUIUpdate()
            Case $iMsg = $hNext
                $iStartIndex = $iStartIndex + 30
                _GUIUpdate()
            Case $iMsg = $hToggle
                If $iOrdinal = -1 Then
                    $iOrdinal = 1
                    GUICtrlSetData($hToggle, "by Ordinal")
                    WinSetTitle($hGui, "", "Icon Selector by Name value")
                Else
                    $iOrdinal = -1
                    GUICtrlSetData($hToggle, "by Name")
                    WinSetTitle($hGui, "", "Icon Selector by Ordinal value")
                EndIf
                _GUIUpdate()
            Case $iMsg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
    WEnd
EndFunc   ;==>_Main

; Just updates GUI icons, labels and set state of "Previous" button
Func _GUIUpdate()
    For $iCntRow = 0 To 4
        For $iCntCol = 0 To 5
            $iCurIndex = $iCntRow * 6 + $iCntCol
            GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename, $iOrdinal * ($iCurIndex + $iStartIndex))
            If $iOrdinal = -1 Then
                GUICtrlSetData($ahLabels[$iCurIndex], -($iCurIndex + $iStartIndex))
            Else
                GUICtrlSetData($ahLabels[$iCurIndex], '"' & ($iCurIndex + $iStartIndex) & '"')
            EndIf
        Next
    Next
    ; This is because we don't want negative values
    If $iStartIndex = 1 Then
        GUICtrlSetState($hPrev, $GUI_DISABLE)
    Else
        GUICtrlSetState($hPrev, $GUI_ENABLE)
    EndIf
EndFunc   ;==>_GUIUpdate

8)

NEWHeader1.png

Link to comment
Share on other sites

Do you want one like this? http://www.autoit.de/index.php?page=Thread...31304#post31304

To get the Code, open the Spoiler with "Anzeigen" and copy it.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Here is simple shell Icons Picker (selector):

$aRet = _PickIconDlg(@SystemDir & "\shell32.dll", 8, WinGetHandle(""))
If Not @error Then MsgBox(64, "Results", StringFormat("IconFile Selected: %s\nIconID Selected: %i", $aRet[0], $aRet[1]))

Func _PickIconDlg($sFileName, $nIconIndex=0, $hWnd=0)
    Local $nRet, $aRetArr[2]
    
    $nRet = DllCall("shell32.dll", "int", "PickIconDlg", _
        "hwnd", $hWnd, _
        "wstr", $sFileName, "int", 1000, "int*", $nIconIndex)
    
    If Not $nRet[0] Then Return SetError(1, 0, -1)
    
    $aRetArr[0] = $nRet[2]
    $aRetArr[1] = $nRet[4]
    
    Return $aRetArr
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Great. Now this one works, too. When I created mine, this dialog had Problems with spaces in AutoIt... But if you want to use an Icon Picker in Windows lower than XP, you have to create your own.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Well, I made my Picker to interact directly with AutoIt, which uses negative numbers. But I added an optional Parameter to chage to 0-based :)

And returns error when no Icon selected.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Here is simple shell Icons Picker (selector):

$aRet = _PickIconDlg(@SystemDir & "\shell32.dll", 8, WinGetHandle(""))
If Not @error Then MsgBox(64, "Results", StringFormat("IconFile Selected: %s\nIconID Selected: %i", $aRet[0], $aRet[1]))

Func _PickIconDlg($sFileName, $nIconIndex=0, $hWnd=0)
    Local $nRet, $aRetArr[2]
    
    $nRet = DllCall("shell32.dll", "int", "PickIconDlg", _
        "hwnd", $hWnd, _
        "wstr", $sFileName, "int", 1000, "int*", $nIconIndex)
    
    If Not $nRet[0] Then Return SetError(1, 0, -1)
    
    $aRetArr[0] = $nRet[2]
    $aRetArr[1] = $nRet[4]
    
    Return $aRetArr
EndFuncoÝ÷ Ûú®¢×ßÙ®²)à2°«y«h¬[§rب»­«âk¢æå{­Øb±«­¢+Ø¥¹±Õ±Ðí ÕÑѽ¹
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíU%
½¹ÍѹÑÍà¹ÔÌÐì(¥¹±Õ±ÐíMÑÑ¥
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±Ðí]¥¹½ÝÍ
½¹ÍѹÑ̹ÔÌÐì(((ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½Ðí½É´ÄÅÕ½Ðì°ÈØÌ°ÄàÄ°ÈÄÄ°ÈÀȤ(ÀÌØí    ÕÑѽ¸ÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíM±Ð%½¸ÅÕ½Ðì°ÜÈ°ÈаäÜ°ÈÔ°À¤)U%MÑMÑÑ¡M]}M!=¤(()]¡¥±Ä($ÀÌØíµÍôU%Ñ5Í ¤(%M±Ð($%
ÍÀÌØíµÍôÀÌØí    ÕÑѽ¸Ä($$$ÀÌØíIÐõ}A¥­%½¹±¡MåÍѵ¥ÈµÀìÅÕ½ÐìÀäÈíÍ¡±°Ìȹ±°ÅÕ½Ðì°à°]¥¹Ñ!¹± ÅÕ½ÐìÅÕ½Ð줤($$%%9½ÐÉɽÈQ¡¸5Í  ½à ØаÅÕ½ÐíIÍÕ±ÑÌÅÕ½Ðì°MÑÉ¥¹½ÉµÐ ÅÕ½Ðí%½¹¥±M±ÑèÌÀäÈí¹%½¹%M±Ñè¤ÅÕ½Ðì°ÀÌØíIÑlÁt°ÀÌØíIÑlÅt¤¤($$%U%
Ñɱ
ÉÑ%½¸ ÀÌØíIÑlÁt°ÀÌØíIÑlÅt°ÄÈÈ°ÔȤ($%ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M($$%á¥Ð(%¹M±Ð)]¹)Õ¹}A¥­%½¹± ÀÌØíÍ¥±9µ°ÀÌØí¹%½¹%¹àôÀ°ÀÌØí¡]¹ôÀ¤(1½°ÀÌØí¹IаÀÌØíIÑÉÉlÉt((ÀÌØí¹IÐô±±
±° ÅÕ½ÐíÍ¡±°Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíA¥­%½¹±ÅÕ½Ðì°|(ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí¡]¹°|(ÅÕ½ÐíÝÍÑÈÅÕ½Ðì°ÀÌØíÍ¥±9µ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÄÀÀÀ°ÅÕ½Ðí¥¹Ð¨ÅÕ½Ðì°ÀÌØí¹%½¹%¹à¤((%9½ÐÀÌØí¹IÑlÁtQ¡¸IÑÕɸMÑÉÉ½È Ä°À°´Ä¤((ÀÌØíIÑÉÉlÁtôÀÌØí¹IÑlÉt(ÀÌØíIÑÉÉlÅtôÀÌØí¹IÑlÑt((IÑÕɸÀÌØíIÑÉÈ)¹Õ¹

The result on msgbox is true, but the result preview in the gui is wrong... always change... Why? am i doing wrong? help me.. :)

@ProgAndy, thanks... i can use it now, but i'm trying on MrCreator's above.. am i doing wrong with that?

Link to comment
Share on other sites

Well, as i said, AutoIt uses negative numbers beginning with -1 as Icon Index. Positive numbers are Icon IDs. THey don't have to be the same like the Index. :) Windows uses #1, #2 ,... as ID and positive numbers as index ( 0,1,2,...)

To use the Windwos index in AutoIt, transform it:

GUICtrlDelete($ICON)

$ICON = GUICtrlCreateIcon($aRet[0],($aRet[1]+1)*(-1), 122, 52)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Well, as i said, AutoIt uses negative numbers beginning with -1 as Icon Index. Positive numbers are Icon IDs. THey don't have to be the same like the Index. :idiot: Windows uses #1, #2 ,... as ID and positive numbers as index ( 0,1,2,...)

To use the Windwos index in AutoIt, transform it:

GUICtrlDelete($ICON)

$ICON = GUICtrlCreateIcon($aRet[0],($aRet[1]+1)*(-1), 122, 52)

Thank's !! >_<

Now I'm Know It! :)

i'm success with this but getting error

i've getting error if i press close or cancel while selecting icon.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 263, 181, 211, 202)
$Button1 = GUICtrlCreateButton("Select Icon", 72, 24, 97, 25, 0)
GUISetState(@SW_SHOW)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button1
            $aRet =_PickIconDlg(@SystemDir & "\shell32.dll", 8, WinGetHandle(""))
            If Not @error Then MsgBox(64, "Results", StringFormat("IconFile Selected: %s\nIconID Selected: %i", $aRet[0], $aRet[1]))
            GUICtrlCreateIcon($aRet[0],($aRet[1]+1)*(-1), 122, 52)
            GUICtrlSetImage(-1,$aRet[0],($aRet[1]+1)*(-1))
        case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
Func _PickIconDlg($sFileName, $nIconIndex=0, $hWnd=0)
    Local $nRet, $aRetArr[2]
   
    $nRet = DllCall("shell32.dll", "int", "PickIconDlg", _
        "hwnd", $hWnd, _
        "wstr", $sFileName, "int", 1000, "int*", $nIconIndex)
   
    If Not $nRet[0] Then Return SetError(1, 0, -1)
   
    $aRetArr[0] = $nRet[2]
    $aRetArr[1] = $nRet[4]
   
    Return $aRetArr
EndFunc

The message from scite like this

if i press close or cancel.

D:\Doc's\AUTOIT Files\iconselector.au3 (18) : ==> Subscript used with non-Array variable.:

GUICtrlCreateIcon($aRet[0],($aRet[1]+1)*(-1), 122, 52)

GUICtrlCreateIcon($aRet^ ERROR

Anybody have solution?

Edited by member429
Link to comment
Share on other sites

Well 1) don't create an Icon each time you open a new :)

create it when you create the Gui

$Icon_Ctrl = GUICtrlCreateIcon("","",, 122, 52)

and change the Icon with the following line:

If Not @error Then GUICtrlSetImage($Icon_Ctrl,$aRet[0],($aRet[1]+1)*(-1))

( it needs to be tesed on error, because it doesn't return an array then.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Well 1) don't create an Icon each time you open a new >_<

create it when you create the Gui

$Icon_Ctrl = GUICtrlCreateIcon("","",, 122, 52)

and change the Icon with the following line:

If Not @error Then GUICtrlSetImage($Icon_Ctrl,$aRet[0],($aRet[1]+1)*(-1))

( it needs to be tesed on error, because it doesn't return an array then.

Working! :)

Thank's a lot :idiot:

Link to comment
Share on other sites

Little another example:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 263, 181, 211, 202)

$Button1 = GUICtrlCreateButton("Select Icon", 72, 24, 97, 25, 0)

$icon = GUICtrlCreateIcon("", "", 100, 65)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button1
            $aRet =_PickIconDlg(@SystemDir & "\shell32.dll", 8, WinGetHandle(""))
            If Not @error Then GUICtrlSetImage($icon, $aRet[0], -$aRet[1] - 1)
        case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func _PickIconDlg($sFileName, $nIconIndex=0, $hWnd=0)
    Local $nRet, $aRetArr[2]
   
    $nRet = DllCall("shell32.dll", "int", "PickIconDlg", _
        "hwnd", $hWnd, _
        "wstr", $sFileName, "int", 1000, "int*", $nIconIndex)
   
    If Not $nRet[0] Then Return SetError(1, 0, -1)
   
    $aRetArr[0] = $nRet[2]
    $aRetArr[1] = $nRet[4]
   
    Return $aRetArr
EndFunc

:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...