 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
PickIconDlg Guest
|
Posted: Sat Feb 17, 2007 9:41 am Post subject: Call PickIconDlg (the icon select dialog) |
|
|
| How can i call this ? Anyone with an example script .. |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Feb 17, 2007 5:38 pm Post subject: |
|
|
| Anyone ?? help please.. |
|
| Back to top |
|
 |
Zipp() Guest
|
Posted: Sat Feb 17, 2007 7:44 pm Post subject: |
|
|
This seems to work:
| Code: | 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. |
|
| Back to top |
|
 |
Zippo() Guest
|
Posted: Sat Feb 17, 2007 8:05 pm Post subject: |
|
|
Nvm, IconPath isn't getting updated.
Always hated working with Dlls from AHK
I'll play with it some more  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2225
|
Posted: Sun Feb 18, 2007 12:41 am Post subject: |
|
|
Try this:
| Code: |
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
|
|
|
| Back to top |
|
 |
Zippo() Guest
|
Posted: Sun Feb 18, 2007 1:38 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
PickIconDlg Guest
|
Posted: Sun Feb 18, 2007 10:58 am Post subject: |
|
|
| Sean wrote: | Try this:
| Code: |
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  |
|
| Back to top |
|
 |
PickIconDlg Guest
|
Posted: Sun Feb 18, 2007 10:59 am Post subject: |
|
|
| BTW, why the Gui Show line ? |
|
| Back to top |
|
 |
PickIconDlg again Guest
|
Posted: Sun Feb 18, 2007 11:01 am Post subject: |
|
|
Oh.. to get the window handle... but the script works without that  |
|
| Back to top |
|
 |
ladiko
Joined: 14 Jul 2006 Posts: 281 Location: Berlin
|
Posted: Wed Mar 12, 2008 12:01 pm Post subject: |
|
|
| Code: | If !DllCall("shell32\PickIconDlg" , "Uint" , hWnd , "str" , wSourceFile , "Uint" , 260 , "intP" , nIndex)
Return ; cancel was clicked or something else failed |
|
|
| Back to top |
|
 |
Fordi Guest
|
Posted: Tue Aug 25, 2009 3:50 pm Post subject: No Window |
|
|
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:
| Code: | 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 |
|
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 7698 Location: Germany (but I only speak English)
|
Posted: Tue Aug 25, 2009 3:53 pm Post subject: |
|
|
Why are you bringing up this old topic?
In general, I would point to majkinetor's excellent Dlg module: http://www.autohotkey.com/forum/viewtopic.php?t=17230
It directly handles the icon box code for you. _________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|