If you please indicate the FWH version you are using, we can advise a solution most appropriate for the FWH version.
How oCol:AddBitmap( aArray ) works:TXBrwColumn object internally maintains an array of bitmaps oCol:aBitmaps.
When we first call oCol:AddBitmap( { bmp1, bmp2, bmp3 } ), oCol:aBitmaps is filed with { bmp1, bmp2, bmp3 }.
If we call oCol:AddBitmap( { new1, new2, new3 } ) these new bitmaps are added to the existing oCol:aBitmaps but do not replace the existing bitmaps.
Now the oCol:aBitmaps is { bmp1, bmp2, bmp3, new1, new2 new3 }
So, If oCol:bBmpNo returns 1 it still shows bmp1 only not new1.
If we want to replace existing bitmaps, then
- Code: Select all Expand view RUN
AEval( oCol:aBitmaps, { |b| PalBmpFree( b ) } )
oCol:aBitmaps := {}
oCol:AddBitmap( { new1, new2, new3 } )
// Now oCol:aBitmaps is { new1, new2, new3 }
So, oCol:AddBitmap() and oCol:bBmpNo are not suitable for dynamic arrays of images.
In such cases, we recommend an approach similar to the sample given below:- Code: Select all Expand view RUN
#include "fivewin.ch"
function Main()
local oDlg, oBrw, oFont
local aData := ;
{ { "browse", "c:\fwh\bitmaps\32x32\browse.bmp" } ;
, { "button", "c:\fwh\bitmaps\32x32\button.bmp" } ;
, { "calc", "c:\fwh\bitmaps\32x32\calc.bmp" } ;
, { "copy", "c:\fwh\bitmaps\32x32\copy.bmp" } ;
}
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 340,400 PIXEL FONT oFont
@ 35,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE aData COLUMNS 1, 2 ;
HEADERS "NAME", "BMP" ;
CELL LINES NOBORDER AUTOSORT
WITH OBJECT oBrw
:nStretchCol := 1
WITH OBJECT :aCols[ 2 ]
:cDataType := "F"
:lBmpTransparent := .t.
:nDataBmpAlign := AL_CENTER
END
//
:CreateFromCode()
END
@ 10,10 BUTTON "ADD-1" SIZE 40,15 PIXEL OF oDlg ;
ACTION ( AAdd( oBrw:aArrayData, { "attach", "c:\fwh\bitmaps\32x32\attach.bmp" } ), ;
oBrw:Refresh() )
@ 10,60 BUTTON "ADD-2" SIZE 40,15 PIXEL OF oDlg ;
ACTION ( AAdd( oBrw:aArrayData, { "floppy", "c:\fwh\bitmaps\32x32\floppy.bmp" } ), ;
oBrw:Refresh() )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
If your requirement is different, please let us know and we will provide a suitable solution.
Please indicate your FWH version.