I think this is what you originally wanted.
Code: Select all
#include "FiveWin.Ch"
#include "xbrowse.ch"
#define DT_LEFT 0x00000000
#define DT_CENTER 0x00000001
#define DT_VCENTER 0x00000004
#define BRW_COLS 6
//----------------------------------------------------------------------------//
static aImg
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBrw, nCol, oFont
aImg := ReadImages( "C:\\FWH\\BITMAPS\\" )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE 812,498 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
AUTOCOLS ARRAY aImg LINES NOBORDER
for nCol := 1 to Len( oBrw:aCols )
WITH OBJECT oBrw:aCols[ nCol ]
:nWidth := 120
:oDataFont := oFont
:nDataBmpAlign := AL_CENTER
:bPaintText := { | oCol, hDC, cData, aRect, aColors, lHighLite | ;
DrawCell( oCol, hDC, cData, aRect, aColors, lHighLite ) }
END
next
WITH OBJECT oBrw
:nRowHeight := 140
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
return (0)
//----------------------------------------------------------------------------//
static function ReadImages( cFolder )
local aFiles := DIRECTORY( cFolder + "*.*" )
local nLen := Len( aFiles )
local nRows := Ceiling( Len( aFiles ) / BRW_COLS )
local nRow, nCol, n, cFile
aImg := Array( nRows, BRW_COLS )
nRow := 1
nCol := 1
for n := 1 to nLen
cFile := aFiles[ n, 1 ]
aImg[ nRow, nCol ] := cFolder + cFile
nCol++
if nCol > BRW_COLS
nRow++
nCol := 1
endif
next n
return aImg
//----------------------------------------------------------------------------//
static function DrawCell( oCol, hDC, cData, aRect, aColors, lHighLite )
local oBrw := oCol:oBrw
local nTop := aRect[ 1 ]
local nLeft := aRect[ 2 ]
local nBottom := aRect[ 3 ]
local nRight := aRect[ 4 ]
local hBrush := CreateSolidBrush( CLR_YELLOW )
local hBmp, hBmpO, nBmpW, nBmpH, nBmpTop, nBmpLeft
local nOldColor
if ! Empty( cData )
hBmp := FILoadImg( cData )
nBmpH := nBmpHeight( hBmp )
nBmpW := nBmpWidth( hBmp )
if nBmpW > 116
nBmpH *= ( 116 / nBmpW )
nBmpW := 116
endif
if nBmpH > 116
nBmpW *= ( 116 / nBmpH )
nBmpH := 116
endif
if nBmpW != nBmpWidth( hBmp ) .or. nBmpH != nBmpHeight( hBmp )
hBmpO := hBmp
hBmp := ResizeBmp( hBmpO, nBmpW, nBmpH )
endif
nBmpTop := nTop + ( 116 - nBmpH ) / 2
nBmpLeft := nLeft + ( 116 - nBmpW ) / 2
if HasAlpha( hBmp )
ABPaint( hDC, nBmpLeft, nBmpTop, hBmp, oCol:nAlphaLevel() )
else
DrawBitmap( hDC, hBmp, nBmpTop, nBmpLeft )
endif
DeleteObject( hBmp )
DeleteObject( hBmpO )
endif
DrawHorz( hDC, nTop + 120, nLeft - 4, nRight + 3, oBrw:hRowPen )
FillRect( hDC, { nTop + 121, nLeft - 3, nBottom, nRight }, hBrush )
if ! Empty( cData )
nOldColor := SetBkColor( hDC, CLR_YELLOW )
DrawTextEx( hDC, cFileNoPath( cData ), { nTop + 121, nLeft, nBottom, nRight }, ;
DT_CENTER + DT_VCENTER )
SetBkColor( hDC, nOldColor )
endif
DeleteObject( hBrush )
return nil
//----------------------------------------------------------------------------//