Jump to content

(Newbie) How to create a dialog to get an icon from *.icl, *.dll...


Recommended Posts

I have a button and i want when i click it, it will appear this dialog like this:

Posted Image

And when i choose an icon, it will show the URL of this Icon with Icon Index such as "C:\windows\system32\SHELL32.dll,13"

How can i code it?

Edited by LeHuynhNam

4m848p10.gif 

Link to comment
Share on other sites

If you had used search you would have found This


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

If you had used search you would have found This

Thank you! I've lost this example for a long time!

I'll search carefully before i post!

but in this topic, i mean i can directly call external DLL and Windows API functions with autoits and it will appear this dialog which is default of windows XP! How can i call and use it?

Edited by LeHuynhNam

4m848p10.gif 

Link to comment
Share on other sites

Theres a func in post #10 in the same thread :)

*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

I did with this guide but when i click cancel button of this dialog it stopped running and exit code! How can i resolve it?

You can add this

If Not @error Then
   <your code here>
else
   <Your code here>

So The script like this

#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))
            Else
                MsgBox(64, "Error", "Please Select an Icon!")
            EndIf
            
        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

Good luck :)

Link to comment
Share on other sites

You can add this

If Not @error Then
   <your code here>
else
   <Your code here>

So The script like this

#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))
            Else
                MsgBox(64, "Error", "Please Select an Icon!")
            EndIf
            
        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

Good luck :)

Thanks for quick reply

4m848p10.gif 

Link to comment
Share on other sites

oh, i want to set the URL of this icon which i had choosen to the $input, what should i do? and i have this code:

$input1 = GUICtrlCreateCombo ("", 288, 172, 57, 21,0x2042,-1)

_GUICtrlComboBox_LimitText($input1,1)

GUICtrlSetTip(-1, "Choose a drive you want to change icon")

For $i = 1 To $odd[0]

GUICtrlSetData ($input1, $odd[$i], $odd[1])

Next

GUISetState ()

but it shows C: or D:.. I want it only show C or D, what should i do?

4m848p10.gif 

Link to comment
Share on other sites

oh, i want to set the URL of this icon which i had choosen to the $input, what should i do? and i have this code:

$input1 = GUICtrlCreateCombo ("", 288, 172, 57, 21,0x2042,-1)

_GUICtrlComboBox_LimitText($input1,1)

GUICtrlSetTip(-1, "Choose a drive you want to change icon")

For $i = 1 To $odd[0]

GUICtrlSetData ($input1, $odd[$i], $odd[1])

Next

GUISetState ()

but it shows C: or D:.. I want it only show C or D, what should i do?

Use StringTrimRight()

Example:

$result = StringTrimRight("C:", 1)
MsgBox(0, "result", $result)
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...