PDA

Click to See Complete Forum and Search --> : SHChangeIconDialog


blitzer
Jul 25th, 2001, 07:10 PM
I wonder how to use the "SHChangeIconDialog"?
I found some code(below) but it didn't get me the filename of the selected file.

here's the code:

Declare Function SHChangeIconDialog Lib "Shell32.DLL" Alias "#62" (ByVal hWndOwner As Long, ByVal szInitFilename As String, ByVal dwReserved As Long, lpIconIndex As Long) As Long

Function DisplayChangeIconDialog(FileName As String, Optional ByVal hWndOwner As Long = 0, Optional IconIndex = 0, Optional ByVal GetHandle As Boolean = True) As Long
Dim a As String
If SHChangeIconDialog(hWndOwner, FileName, 0, IconIndex) = 0 Then Exit Function ' Failure? Exit Function
If GetHandle Then
DisplayChangeIconDialog = ExtractAssociatedIcon(App.hInstance, FileName, IconIndex) ' Extract the icon
' Do NOT forget to DeleteObject it when you are done!!!
Else
DisplayChangeIconDialog = -1 ' Success but do nothing... FileName and IconIndex are returned ByRef anyway
End If
End Function8

'Ends here

and this is how I called it


myicon = DisplayChangeIconDialog(myfile, , iconnum, True)



please help me =]

jim mcnamara
Jul 25th, 2001, 09:08 PM
|Try this:

Private Declare Function SHChangeIconDialog Lib "shell32" Alias "#62" (ByVal hOwner As Long, ByVal szFilename As String, ByVal R As Long, lpIconIndex As Long) As Long

Private Sub Form_Load()
SHChangeIconDialog Me.hWnd, "shell32.dll", 0, 0
End Sub



This api is unsupported, ie., subject to being dropped or changed.

blitzer
Jul 30th, 2001, 07:43 AM
thanks, but that wasn't really my problem :(

the problem is how to get the filename from the dialog when I choose to "browse" for a file.

=]

blitzer
Aug 1st, 2001, 06:21 PM
please help....