AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Call PickIconDlg (the icon select dialog)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
PickIconDlg
Guest





PostPosted: Sat Feb 17, 2007 9:41 am    Post subject: Call PickIconDlg (the icon select dialog) Reply with quote

How can i call this ? Anyone with an example script ..
Back to top
Guest






PostPosted: Sat Feb 17, 2007 5:38 pm    Post subject: Reply with quote

Anyone ?? help please..
Back to top
Zipp()
Guest





PostPosted: Sat Feb 17, 2007 7:44 pm    Post subject: Reply with quote

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





PostPosted: Sat Feb 17, 2007 8:05 pm    Post subject: Reply with quote

Nvm, IconPath isn't getting updated.

Always hated working with Dlls from AHK

I'll play with it some more Very Happy
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Sun Feb 18, 2007 12:41 am    Post subject: Reply with quote

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
View user's profile Send private message
Zippo()
Guest





PostPosted: Sun Feb 18, 2007 1:38 am    Post subject: Reply with quote

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 Smile
Back to top
PickIconDlg
Guest





PostPosted: Sun Feb 18, 2007 10:58 am    Post subject: Reply with quote

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 Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy
Back to top
PickIconDlg
Guest





PostPosted: Sun Feb 18, 2007 10:59 am    Post subject: Reply with quote

BTW, why the Gui Show line ?
Back to top
PickIconDlg again
Guest





PostPosted: Sun Feb 18, 2007 11:01 am    Post subject: Reply with quote

Oh.. to get the window handle... but the script works without that Very Happy
Back to top
ladiko



Joined: 14 Jul 2006
Posts: 167
Location: Berlin

PostPosted: Wed Mar 12, 2008 12:01 pm    Post subject: Reply with quote

Code:
If !DllCall("shell32\PickIconDlg" , "Uint" , hWnd , "str" , wSourceFile , "Uint" , 260 , "intP" , nIndex)
   Return ; cancel was clicked or something else failed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group