#include "FiveWin.Ch"
#include "xbrowse.ch"
#define DT_LEFT 0x00000000
#define DT_VCENTER 0x00000004
//----------------------------------------------------------------------------//
static aImg
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBrw, nCol, oVert
aImg := ReadImages( "C:\\FWH\\BITMAPS\\" )
DEFINE FONT oVert NAME "TAHOMA" SIZE 0,-12 NESCAPEMENT 900 BOLD
DEFINE DIALOG oDlg SIZE 522,560 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
AUTOCOLS ARRAY aImg CELL LINES NOBORDER
for nCol := 1 to 5 step 2
WITH OBJECT oBrw:aCols[ nCol ]
:nWidth := 120
:cDataType := 'F'
:nDataBmpAlign := AL_CENTER
END
WITH OBJECT oBrw:aCols[ nCol + 1 ]
:oDataFont := oVert
:nWidth := 24
:bPaintText := { | oCol, hDC, cData, aRect, aColors, lHighLite | ;
DrawVertText( oCol, hDC, cData, aRect, aColors, lHighLite ) }
END
next
WITH OBJECT oBrw
:nRowHeight := 120
: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 ) / 3 )
local nRow, nCol, n, cFile
aImg := Array( nRows, 6 )
nRow := 1
nCol := 1
for n := 1 to nLen
cFile := aFiles[ n, 1 ]
aImg[ nRow, nCol ] := cFolder + cFile
aImg[ nRow, nCol + 1 ] := cFile
nCol += 2
if nCol > 6
nRow++
nCol := 1
endif
next n
return aImg
//----------------------------------------------------------------------------//
static function DrawVertText( 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 nTxtWidth := oBrw:GetWidth( cData, oCol:oDataFont )
local nTxtHeight := GetTextHeight( oBrw:hWnd, hDC )
nBottom := ( nTop + nBottom + nTxtWidth ) / 2
nLeft := ( nLeft + nRight - nTxtHeight ) / 2
DrawTextEx( hDC, cData, { nBottom, nLeft, nTop, nRight }, DT_LEFT + DT_VCENTER )
return nil
//----------------------------------------------------------------------------//
if ! Empty( cImagen ) .or. ::cDataType $ "FP" // IMAGE
if ! Empty( cImagen )
hBmp := FILoadFromMemory( cImagen )
else
if ::bStrImage == NIL
cImagen := ::Value()
else
cImagen := Eval( ::bStrImage, Self, ::oBrw )
endif
if ::cDataType == 'F' .and. File( cImagen )
hBmp := FILoadImg( cImagen )
else
hBmp := FILoadFromMemory( cImagen )
endif
endif
hBmp := FILoadFromMemory( cImagen )
hBmp := FILoadFromMemory( IfNil( cImagen, '' ) )
if ::cDataType == 'F' .and. File( cImagen )
hBmp := FILoadImg( cImagen )
else
hBmp := FILoadFromMemory( IfNil( cImagen, '' ) ) // change !!!!!!
endif
The same, 10 Lines down from the change, must be changed as well :
#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
//----------------------------------------------------------------------------//
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 nold, lAlpha, nZeroClr
if ! Empty( cData := oCol:Value() ) // note: cData is reassigned
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
nBmpTop := nTop + ( 116 - nBmpH ) / 2
nBmpLeft := nLeft + ( 116 - nBmpW ) / 2
lAlpha := HasAlpha( hBmp )
if lAlpha .or. ! oCol:lBmpTransparent
if nBmpW != nBmpWidth( hBmp ) .or. nBmpH != nBmpHeight( hBmp )
hBmpO := hBmp
hBmp := ResizeImg( hBmpO, nBmpW, nBmpH )
DeleteObject( hBmpO )
endif
endif
if lAlpha
ABPaint( hDC, nBmpLeft, nBmpTop, hBmp, oCol:nAlphaLevel() )
elseif oCol:lBmpTransparent
nZeroClr := GetZeroZeroClr( hDC, hBmp )
nold := SetBkColor( hDC, nRGB( 255, 255, 255 ) )
TransBmp( hBmp, nBmpWidth( hBmp ), nBmpHeight( hBmp ),;
nZeroClr, hDC, nBmpLeft, nBmpTop, nBmpW, nBmpH )
SetBkColor( hDC, nold )
else
DrawBitmap( hDC, hBmp, nBmpTop, nBmpLeft )
endif
DeleteObject( hBmp )
endif
DrawHorz( hDC, nTop + 120, nLeft - 4, nRight + 3, oBrw:hRowPen )
FillRect( hDC, { nTop + 121, nLeft - 3, nBottom, nRight }, hBrush )
if ! Empty( cData )
nold := SetBkColor( hDC, CLR_YELLOW )
DrawTextEx( hDC, cFileNoPath( cData ), { nTop + 121, nLeft, nBottom, nRight }, ;
DT_CENTER + DT_VCENTER )
SetBkColor( hDC, nold )
endif
DeleteObject( hBrush )
return nil
//----------------------------------------------------------------------------//
static function GetZeroZeroClr( hDC, hBmp )
local hDCMem, hOldBmp, nZeroZeroClr
hDCMem = CreateCompatibleDC( hDC )
hOldBmp = SelectObject( hDCMem, hBmp )
nZeroZeroClr = GetPixel( hDCMem,0,0)
SelectObject( hDCMem, hOldBmp )
DeleteDC( hDCMem )
return nZerozeroClr
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 87 guests