home *** CD-ROM | disk | FTP | other *** search
- #include "fivewin.ch"
- #include "directry.ch"
-
- #define MAXWIDTH 180
- #define MAXHEIGHT 180
-
- function Viewer()
-
- Local oViewer
- Local cVar1 , cVar2 := ""
-
- Local aItems1 := {}, aItems2 := {}
- Local aFiles := {}
- Local oFont
- local n, nLen
-
- Public oLbx1, oLbx2, oBmp
- Public aSelItems := {}
-
- Public cUnidad := CurDrive()
- Public cPath := cUnidad + ":\" + Curdir (CurDrive())
- Public cDrives := aDrives()
-
-
- aItems1 := Filldir ()
-
- nLen := Len( cDrives )
-
- if nLen == 0
- quit
- endif
-
- for n := 1 to nLen
- aadd( aItems1, "[-" + substr( cDrives,n,1) + "-]" )
- next
-
- cVar1 := aItems1[1]
-
- DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0,-10
- ACTIVATE FONT oFont
-
- DEFINE DIALOG oViewer NAME "BMPVIEWER" FONT oFont
-
-
- REDEFINE LISTBOX oLbx1 ;
- VAR cVar1 ;
- ID 101 ;
- ITEMS aItems1 ;
- OF oViewer ;
- COLOR CLR_BLACK, CLR_WHITE ;
- ON DBLCLICK Pulsado ( oLbx1, , oLbx2 ) ;
- MULTISEL
-
- oLbx1:bKeyDown := {|nKey| Pulsado ( oLbx1, nKey )}
- oLbx1:bRClicked := {|nRow,nCol| MenuTool(nROw,nCol,oLbx1)}
-
- REDEFINE LISTBOX oLbx2 ;
- VAR cVar2 ;
- ID 102 ;
- ITEMS aItems2 ;
- SIZE 128, 184 ;
- OF oViewer ;
- COLOR CLR_BLACK, CLR_WHITE ;
- ON DBLCLICK Pulsado ( oLbx1, , oLbx2 ) ;
- ON CHANGE if ( UPPER(right(oLbx2:GetSelText(),3 )) == "BMP", Pulsado( oLbx1,,oLbx2 ),.t.)
-
-
- REDEFINE BITMAP oBmp FILE " " ;
- ID 103 ;
- OF oViewer ;
- NOBORDER
-
-
-
-
- ACTIVATE DIALOG oViewer CENTERED
-
- RELEASE FONT oFont
-
-
- Return nil
-
-
-
- Function filldir ( cSort, lFiles )
-
- Local aDir
- Local aFiles1 := {}
- Local aFiles2 := {}
-
- Local n, nLen
-
- DEFAULT cSort := "name", lFiles := .f.
-
-
- aDir := DIRECTORY (cPath + "\" + "*.*","D" )
-
- IF !empty ( aDir )
-
- nLen := Len (aDir)
-
- For n := 1 to nLen
- aDir [n][1] := iif ( aDir[n,F_ATTR] != "D", Lower (aDir[n,1]), aDir [n,1] )
- next
-
- If cSort == "name"
- aDir := ASORT (aDir, iif(aDir[1][1] == ".",3,1) ,, { |x,y| x[1] < y[1] } )
- else
- aDir := ASORT (aDir, iif(aDir[1][1] == ".",3,1) ,, { |x,y| cFileExt(x[1])+cFileName(x[1]) < cFileExt(y[1])+cFileName(y[1]) } )
- endif
-
- If !lFiles
- AEVAL ( aDir, {|aFichero,n| iif ( aDir[n][5] == "D",aadd( aFiles1, aFichero[F_NAME] ), ) } )
- else
- AEVAL ( aDir, {|aFichero,n| iif ( aDir[n][5] != "D",aadd( aFiles1, aFichero[F_NAME] ), ) } )
- endif
-
-
-
- endif
-
-
- Return aFiles1
-
- ****************************************
- Function Pulsado ( oLbx1, nKey , oLbx2, nListbox )
- ****************************************
- Local cAuxPath, aAux := {}, aFiles := {}
- Local cItem := ""
- Local cItem2 := ""
-
- If nKey != nil
- if ! (nKey == VK_RETURN .or. nKey == VK_SPACE)
- Return nil
- endif
- endif
-
-
- cItem := alltrim ( oLbx1:GetItem (oLbx1:GetPos()) )
- cItem2 := alltrim ( oLbx2:GetItem (oLbx2:GetPos()) )
-
-
- cExt = RIGHT (cItem2, 3)
-
-
- DO CASE
- CASE cExt == "bmp"
-
- oBmp:LoadBMP( cPath + "\" + cItem2 )
-
- if oBmp:nWidth > MAXWIDTH .or. ;
- oBmp:nHeight > MAXHEIGHT
- oBmp:lStretch := .t.
- else
- oBmp:lStretch := .f.
- endif
-
- Return nil
-
- * CASE cExt == "exe"
- *
- * winexec( cPath + "\" + cItem )
- * Return nil
-
- CASE cItem == ".."
-
- cAuxPath := substr ( cPath, 1, RAT ("\",cPath) - 1 )
-
- cPath := cAuxPath
-
-
- CASE ISUPPER ( SUBSTR ( cItem, 1, 1) )
-
-
- cAuxPath := cPath + "\"+ cItem
-
- cPath := cAuxPath
-
-
-
- CASE SUBSTR(cItem,1,1) == "["
-
- // voy a cambiar a una unidad
-
- cUnidad := SUBSTR(cItem,3,1)
-
- cPath := cUnidad + ":"
-
-
- ENDCASE
-
- aAux := FillDir ()
- aFiles := FillDir (,.t.)
-
- if !Empty (aAux)
-
- For n := 1 to Len ( cDrives )
- aadd( aAux, "[-" + substr( cDrives,n,1) + "-]" )
- next
-
- oLbx1:SetItems ( aAux )
- oLbx2:SetItems ( aFiles )
-
- else
- MsgStop ("Drive not ready!")
- endif
-
-
- *oWnd:Say (20,20,cPath + SPACE (100) )
-
-
- Return nil
-
- Function MenuTool(nX,nY,oLbx)
- Local n, cAux := ""
-
- Local oMenu
-
- MENU oMenu POPUP
-
- MENUITEM "Copy" ACTION ( ASIZE(aSelItems,0), aeval(oLbx:GetSelItem(),{|x|aadd(aSelItems,oLbx:GetItem( x ))}))
-
- if !empty (aSelItems)
- MENUITEM "Paste" ACTION wqout (aSelItems)
- endif
-
- SEPARATOR
-
- MENUITEM "Ord Nombre" ACTION SortDir ("name")
- MENUITEM "Ord Tipo" ACTION SortDir ("ext")
-
- SEPARATOR
-
- MENUITEM "Borrar"
- SEPARATOR
-
- for n = 1 to Len (cDrives)
-
- cAux := "ChanDriv("+substr( cDrives,n,1)+")"
-
- MENUITEM "[-" + substr( cDrives,n,1) + "-]" ACTION &caux
- next
-
-
-
- ENDMENU
-
- ACTIVATE POPUP oMenu AT nX,nY OF oLbx
-
-
- Return nil
-
-
- Function sortdir ( cPor )
- Local n
-
-
- aAux := FillDir ( cPor )
-
- if !Empty (aAux)
-
- For n := 1 to Len ( cDrives )
- aadd( aAux, "[-" + substr( cDrives,n,1) + "-]" )
- next
-
- oLbx1:SetItems ( aAux )
- else
- MsgStop ("Unidad no disponible")
- endif
-
-
- oWnd:Say (20,20,cPath + SPACE (100) )
-
-
- Return nil
-
-
-
-
- function chandriv (c)
- ? c
- return nil
-
-
-
-