Hi,
I've been reviewing the GridMainDemo in the DevExpress Demos 13.2 folder.
In this demo there are two examples: WinExplorerView and WinExplorerViewDatabaseBinding. In the first you obtain a file's icon (or image) using the IconExtractor class by referencing the file's path using this function:
Public Shared Function GetFileIcon(ByVal path As String, ByVal size As IconSize) As Icon Dim shinfo As New SHFILEINFO() Dim retVal As IntPtr = SHGetFileInfo(path, 0, shinfo, CUInt(Marshal.SizeOf(shinfo)), CUInt(Fix(SHGFI_SYSICONINDEX Or SHGFI_ICON))) Dim iconIndex As Integer = shinfo.iIcon Dim iImageList As IImageList = CType(GetSystemImageListHandle(size), IImageList) Dim hIcon As IntPtr = IntPtr.Zero If iImageList IsNot Nothing Then iImageList.GetIcon(iconIndex, CInt(ILD_TRANSPARENT), hIcon) End If Dim icon As Icon = Nothing If hIcon <> IntPtr.Zero Then icon = TryCast(Icon.FromHandle(hIcon).Clone(), Icon) DestroyIcon(shinfo.hIcon) End If Return icon End Function
However, the file has to physically exist on a drive for this to show the correct icon at the chosen size.
In the second example you retrieve an image to display that has already been saved to the database.
In my case I want to use a combination of both of these examples by saving files (documents) to a database. Now while I know the file type (ie extension) I haven't yet found a way to display the correct icon when referencing only the extension (eg .docx). I don't want to save the file's icon/image to the database when the file is originally saved there for obvious reasons. Instead, I save just the file's extension eg .docx into a varchar(5) field and the document's content to a varchar(max).
Using the DX WinExplorerView I want to be able to display to the user the 'file' icons that correspond to the of the type of file whose data is saved in the database. I can do this for size 16x16 and 32x32 icons/images using win32 system calls but I can't display the 48x48 or 256x256 images.
Are you able to provide a code sample that will allow me to achieve this using your IconExtractor class?
Many thanks