Título: Lista con iconos de archivos Publicado por: ~~ en 16 Diciembre 2006, 20:41 pm Hola:
Bueno estoy intentando hacer un file manager en el q aparezcan los iconos de cada tipo de archivo. Para ello extraigo el icono de el tipo de archivo q me interesa. Este seria un ejemplo: Código: Const DI_MASK = &H1 Hasta el MsgBox todo me funciona perfecto, pero a partir de ahi no, por q no me deja pasar la imagen del picture al Image List (il en el code), por lo q luego no puedo cargarla en la lista... Alguien sabe como puedo hacerlo??? :huh: :huh: Otra duda q se me plantea es de donde sacar los iconos, por q podria buscar por el ordenador q usa el cliente, pero se tardaria muho rato buscando y en caso de q un tipo de archivo (imaginemos q el cliente no tiene Acrobat Reader y el server sip) se tiraria muxo tiempo buscando... Hay algun sitio donde se guarden los iconos o hay q andar buscandolos??? :rolleyes: Ayuda please!!! 1S4ludo Título: Re: Lista con iconos de archivos Publicado por: Snort en 17 Diciembre 2006, 13:51 pm Para buscar las extensiones, pasate por el registro, en la clave HKEY_CLASSES_ROOT estan todas, y dependiendo de la extension tienes mas o menos datos sobre ell, lo minimo es que te ponga, por ejemplo en la extension *.8bf, en la clave (Predeterminado), el programa con el que se abre, en este caso, PhotoshopPlugIn. Pero en las extensiones mas comunes tienes algunos datos mas, mirate la *.txt, por ejemplo. A partir de ahi seguramente habra algun modo de encontrar los iconos respectivos, mirate algun manual de estos de agregar la extension *.troj como ejecutable y que parezca un txt, hay muchos.
Comprueba en las propiedades del listview que puedes meter iconos. Espero qe te sirva de algo, saludos Título: Re: Lista con iconos de archivos Publicado por: ~~ en 17 Diciembre 2006, 17:01 pm Gracias por tu ayuda Snort pero KIZAR me a dado una idea mejor, q es ir creando los archivos y funciona a las mil maravillas (ya e acabado el FileManager ;D)
Mirate este (http://www.kizar.net/foro/index.php?topic=362.0) post si te interesa como hacerlo 1S4ludo Título: Re: Lista con iconos de archivos Publicado por: LeandroA en 17 Diciembre 2006, 19:38 pm Un ejemplo muy interesante, Agrega solo un Listview pero que este sea de (Microsoft common controls 5.0(SP2) y no la versión 6.0 y el siguiente codigo
bien lo que hace es crear un imagelist virtual con los iconos correspondiente a las extensiones existentes/asociada , y las va obteniendo desde el registro Citar Option Explicit Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long Const HKEY_CLASSES_ROOT = &H80000000 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Const LVM_FIRST = &H1000 Const LVM_SETIMAGELIST = (LVM_FIRST + 3) Const LVM_SETITEM = (LVM_FIRST + 6) Const LVSIL_SMALL = 1 Const LVIF_IMAGE = &H2 Private Type LV_ITEM mask As Long iItem As Long iSubItem As Long State As Long StateMask As Long lpszText As Long cchTextMax As Long iImage As Long lParam As Long End Type Private Declare Function SHGetFileInfo Lib "shell32" Alias "SHGetFileInfoA" (ByVal pszPath As String, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long Const SHGFI_SYSICONINDEX = &H4000 Const SHGFI_SMALLICON = &H1 Const MAX_PATH = 260 Const FILE_ATTRIBUTE_NORMAL = &H80 Const SHGFI_USEFILEATTRIBUTES = &H10 Const SHGFI_TYPENAME = &H400 Private Type SHFILEINFO hIcon As Long iIcon As Long dwAttributes As Long szDisplayName As String * MAX_PATH szTypeName As String * 80 End Type Private Sub Form_Load() Dim sfi As SHFILEINFO, lvi As LV_ITEM 'set view and add columns ListView1.View = lvwReport ListView1.ColumnHeaders.Add , , "Extension", 600 ListView1.ColumnHeaders.Add , , "Description", 3000 'associate the system image list (small icons) to the list view SendMessage ListView1.hWnd, LVM_SETIMAGELIST, LVSIL_SMALL, ByVal _ SHGetFileInfo("C:\", 0, sfi, Len(sfi), SHGFI_SYSICONINDEX Or SHGFI_SMALLICON) Dim Index As Long, sName As String * 1000 lvi.mask = LVIF_IMAGE 'enumerate all file extensions from registry While RegEnumKeyEx(HKEY_CLASSES_ROOT, Index, sName, Len(sName), ByVal 0, vbNullString, ByVal 0, ByVal 0&) = 0 If Asc(sName) = 46 Then 'retrieve icon index and type description SHGetFileInfo sName, FILE_ATTRIBUTE_NORMAL, sfi, Len(sfi), SHGFI_USEFILEATTRIBUTES Or SHGFI_SMALLICON Or SHGFI_SYSICONINDEX Or SHGFI_TYPENAME 'add the item (and subitem) to the listview ListView1.ListItems.Add(, , sName).SubItems(1) = sfi.szTypeName 'set the icon index of the listitem lvi.iImage = sfi.iIcon lvi.iItem = ListView1.ListItems.Count - 1 SendMessage ListView1.hWnd, LVM_SETITEM, 0, lvi End If Index = Index + 1 Wend End Sub Private Sub Form_Resize() ListView1.Move 0, 0, ScaleWidth, ScaleHeight End Sub Private Sub Form_Unload(Cancel As Integer) 'Disassociate the listview from the system imagelist. 'this MUST be done on Win98 otherwise the system listimage crashes. 'and all icons in the shell are gone!. 'WinXP/2K does not require this. SendMessage ListView1.hWnd, LVM_SETIMAGELIST, LVSIL_SMALL, ByVal 0& End Sub Saludos Título: Re: Lista con iconos de archivos Publicado por: ~~ en 17 Diciembre 2006, 21:13 pm Muy bueno el code LeandroA ;)
Thanks |