The idea is given any existing file, read the icon of the associated application and display.
For example, if the file is "some.xlsx" display the icon of Excel application, for "some.docx", display icon of the Word Application, etc.
Here, we will demonstrate how simple and easy to do this, using FWH.
Please note, we have to use existing file names.
Sample-1
- Code: Select all Expand view
- XIMAGE( "some.pptx(256x256)")
Sample-2
- Code: Select all Expand view
- DEFINE DIALOG oDlg SIZE 510,500 PIXEL TRUEPIXEL
ACTIVATE DIALOG oDlg CENTERED ON PAINT ( ;
oDlg:DrawImage( "some.xlsx(16x16)", {,,,50} ), ;
oDlg:DrawImage( "some.xlsx(32x32)", {,50,,100} ), ;
oDlg:DrawImage( "some.xlsx(64x64)", {,100,,200} ), ;
oDlg:DrawImage( "some.xlsx(256x256)", {,200,,500} ) )
Sample-3:
From next version
- Code: Select all Expand view
- DEFINE DIALOG oDlg SIZE 600,250 PIXEL TRUEPIXEL
DEFINE BUTTONBAR oBar SIZE 80,80 2007
for each c in { "DOCX", "XLSX", "PPTX", "PDF", "TXT" }
DEFINE BUTTON OF oBar PROMPT c FILE "." + c,"." + c,"." + c, "." + c + "(16x16)"
next
ACTIVATE DIALOG oDlg CENTERED
Till FWH2206, we need to use existing file names.
Sample-4
- Code: Select all Expand view
- #include "fivewin.ch"
function Main( cPath )
DEFAULT cPath := "c:\aFiles\" // your folder here
XBROWSER DIRECTORY( cPath + "*.*" ) COLUMNS 1,2,3 ;
TITLE "FILE ICONS" ;
SETUP BrwSetup( oBrw, cPath )
return nil
static function BrwSetup( oBrw, cPath )
WITH OBJECT oBrw
:cHeaders := { "Name","Size","Date" }
:nRowHeight := 34
WITH OBJECT :aCols[ 1 ]
:bBmpData := { || cPath + oBrw:aRow[ 1 ] }
:bLDClickData := { || ShellExecute( 0, "Open", cPath + oBrw:aRow[ 1 ],,, 1 ) }
END
END
return nil
Note: Easy to write but not fully optimized for speed.