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 =]
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 =]