Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Call PickIconDlg (the icon select dialog)


  • Please log in to reply
11 replies to this topic
PickIconDlg
  • Guests
  • Last active:
  • Joined: --
How can i call this ? Anyone with an example script ..

  • Guests
  • Last active:
  • Joined: --
Anyone ?? help please..

Zipp()
  • Guests
  • Last active:
  • Joined: --
This seems to work:
Gui, Show, h100 w100, Test                  ;Simple GUI for a handle

WinGet, hWnd, ID, Test                      ;Get hWnd to window

IconPath = %A_WinDir%Shell32\Shell32.dll    ;Path to any Dll
PathSize := StrLen(IconPath)                ;Length of the path above

Index := 1                                  ;Pre-selected icon number

Dlg := DllCall("Shell32.dll\PickIconDlg", "UInt", hWnd, "UInt*", "IconPath", "UInt", "PathSize", "Int*", Index)

If !Dlg
  {
     MsgBox Call Failed!
     ExitApp
  }

;--- On return, IconPath will hold the Path\Dll name and Index will hold the icon number

MsgBox Icon Path: %IconPath%`nIcon Selected: %Index%

I didn't test it with anything but Shell32.dll tho, so might want do test it well.

Zippo()
  • Guests
  • Last active:
  • Joined: --
Nvm, IconPath isn't getting updated.

Always hated working with Dlls from AHK Posted Image

I'll play with it some more :D

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Try this:

Gui, Show, h100 w100, PickIconDlg

WinGet, hWnd, ID, PickIconDlg

sIconPath := A_WinDir . "\system32\shell32.dll"
nIndex := 0

VarSetCapacity(wIconPath, 260 * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)

DllCall("shell32\PickIconDlg", "Uint", hWnd, "str", wIconPath, "Uint", 260, "intP", nIndex)

VarSetCapacity(sIconPath, 260)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)

MsgBox % sIconPath . "," . nIndex




Zippo()
  • Guests
  • Last active:
  • Joined: --
Glad you posted that. I was about to put my shoes on and go looking for Bill Gates after I did all the Unicode stuff and it wouldn't work on paths with spaces :)

PickIconDlg
  • Guests
  • Last active:
  • Joined: --

Try this:

Gui, Show, h100 w100, PickIconDlg

WinGet, hWnd, ID, PickIconDlg

sIconPath := A_WinDir . "\system32\shell32.dll"
nIndex := 0

VarSetCapacity(wIconPath, 260 * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)

DllCall("shell32\PickIconDlg", "Uint", hWnd, "str", wIconPath, "Uint", 260, "intP", nIndex)

VarSetCapacity(sIconPath, 260)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)

MsgBox % sIconPath . "," . nIndex




THANKS VERY MUCH Sean :D :D :D :D :D :D

PickIconDlg
  • Guests
  • Last active:
  • Joined: --
BTW, why the Gui Show line ?

PickIconDlg again
  • Guests
  • Last active:
  • Joined: --
Oh.. to get the window handle... but the script works without that :D

ladiko
  • Members
  • 290 posts
  • Last active: Jan 16 2012 11:46 PM
  • Joined: 13 Jul 2006
If !DllCall("shell32\PickIconDlg" , "Uint" , hWnd , "str" , wSourceFile , "Uint" , 260 , "intP" , nIndex)

	Return ; cancel was clicked or something else failed


Fordi
  • Guests
  • Last active:
  • Joined: --
If you don't want to deal with the random blank window, you CAN specify null as the hWnd, just like in the Win32 API:
sIconPath := A_WinDir . "\system32\shell32.dll"
nIndex := 0
VarSetCapacity(wIconPath, 260 * 2)
DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "str", sIconPath, "int", -1, "str", wIconPath, "int", 260)
DllCall("shell32\PickIconDlg", "Uint", null, "str", wIconPath, "Uint", 260, "intP", nIndex)
VarSetCapacity(sIconPath, 260)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wIconPath, "int", -1, "str", sIconPath, "int", 260, "Uint", 0, "Uint", 0)
MsgBox % sIconPath . "," . nIndex


engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
Why are you bringing up this old topic?

In general, I would point to majkinetor's excellent Dlg module: <!-- m -->http://www.autohotke...pic.php?t=17230<!-- m -->

It directly handles the icon box code for you.