Jump to content
Sign in to follow this  
Mat

Pick Icon dlg

Recommended Posts

Mat

Is any one else finding this?

I use this to get icon names + indexes, yet when I then use SetIcon or something - it is using the wrong icon.

eg: I want icon 21, and i select it from the dialog, I then copy the result and use it in a script, yet it comes out wrong, but I can correct it by adding 1. I have tried it with lots of things, always with the same result

$Ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*", 0)
InputBox ("Icon", "The icon name is:", FileGetShortName ($Ret[2] & ", " & $Ret[4]), "", -1, 100)

am i going mad?

MDiesel

Share this post


Link to post
Share on other sites
Yashied

Is any one else finding this?

I use this to get icon names + indexes, yet when I then use SetIcon or something - it is using the wrong icon.

eg: I want icon 21, and i select it from the dialog, I then copy the result and use it in a script, yet it comes out wrong, but I can correct it by adding 1. I have tried it with lots of things, always with the same result

$Ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*", 0)
InputBox ("Icon", "The icon name is:", FileGetShortName ($Ret[2] & ", " & $Ret[4]), "", -1, 100)

am i going mad?

MDiesel

GUICtrlCreateIcon($Ret[2], - (1 + $Ret[4]), 40, 40, 32, 32)

Share this post


Link to post
Share on other sites
DeeRiee

Try 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)

$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

^_^


Sorry 4 Bad English, I'm Indonesian...I'm really need 'Translator' for helping me posting in this forum (http://deeriee.wordpress.com)

Share this post


Link to post
Share on other sites
Mat

so i'm not mad then. good. everyones just been adding -1's all along.

$Ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*", 0)
InputBox ("Icon", "The icon name is:", FileGetShortName ($Ret[2]) & ", " & $Ret[4] + 1, "", -1, 100)

thats better!

Edited by mdiesel

Share this post


Link to post
Share on other sites
Yashied

so i'm not mad then. good. everyones just been adding -1's all along.

$Ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", 0, "wstr", "", "int", 1000, "int*", 0)
InputBox ("Icon", "The icon name is:", FileGetShortName ($Ret[2]) & ", " & $Ret[4] + 1, "", -1, 100)

thats better!

No.

- ($Ret[4] + 1)

EDIT: PickIconDlg() returns the correct (zero based) values. If you use GUICtrlCreateIcon() or GUICtrlSetImage() then you need to put a negative value.

Edited by Yashied

Share this post


Link to post
Share on other sites
WideBoyDixon

I believe Yashied. I think the past few days makes Yashied the icon guru ^_^

Share this post


Link to post
Share on other sites
Yashied

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
Sign in to follow this  

×