METHOD New( nTop, nLeft, oWnd, nClrFore,;
nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg, lCheckBoxes, bChange, acResName, acBmpFile ) CLASS TTreeView // añadido ultimo parámetro un array de nombres de bmp en recursos
......
if lDesign
::CheckDots()
endif
IF ! Empty( acResname ) .or. ! Empty( acBmpFile )
::CreateTreeImageList( acResname , acBmpFile ) // procesamos y creamos el ImageList
endif
return Self
ReDefine( nId, oWnd, nClrFore, nClrBack, lDesign, cMsg , bChange,, acResname, acBmpFile ) CLASS TTreeView // añadido ultimo parámetro un array de nombres de bmp en recursos
....
oWnd:DefControl( Self )
IF ! Empty( acResname ) .or. ! Empty( acBmpFile )
::CreateTreeImageList( acResname , acBmpFile ) // procesamos y creamos el ImageList
endif
return Self
//------------------------------------------------------------------------------
METHOD CreateTreeImageList( acResname, acBmpFile ) CLASS TTreeView // nuevo metido procesa el array y crea imagelist
LOCAL i,oBmp
LOCAL nLen
LOCAL oImageList := TImageList():New()
if !Empty (acResname)
nLen:= Len( acResname )
oBmp = TBitmap():Define( acResName[i], ::oWnd )
oImageList:Add( oBmp,setMasked( oBmp:hBitmap, ::nClrPane ) )
endif
if !Empty ( acBmpFile )
nLen:= Len( acBmpFile )
FOR i=1 TO nLen
oBmp = TBitmap():Define( ,acBmpFile[i], ::oWnd )
oImageList:Add( oBmp,setMasked( oBmp:hBitmap, ::nClrPane ) )
NEXT
endif
::SetImageList( oImageList )
RETURN nil
// function setMasked( oBmp , mascara ) que genera la mascara del bmp ... He probado el Methodo de imagelist addmasked y no va como esperaba .
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
void MaskRegion(HDC hdc, RECT * rct,
COLORREF cTransparentColor,
COLORREF cBackgroundColor);
HB_FUNC( SETMASKED ) // ( hBitmap , lMaskColor) --> nil
{
HBITMAP hBitmap ;
DWORD lMaskColor ;
HDC hDC ;
BITMAP Bmp ;
RECT rct ;
hBitmap = ( HBITMAP ) hb_parnl( 1 ) ;
lMaskColor = hb_parnl( 2 ) ;
hDC = CreateCompatibleDC( NULL ) ;
GetObject( hBitmap, sizeof( BITMAP ), ( LPSTR ) &Bmp ) ;
SelectObject( hDC, ( HGDIOBJ ) LOWORD( hBitmap ) ) ;
rct.top = 0 ;
rct.left = 0 ;
rct.right = Bmp.bmWidth - 1 ;
rct.bottom = Bmp.bmHeight -1 ;
MaskRegion( hDC, &rct, GetPixel( hDC, 0, 0 ), lMaskColor ) ;
DeleteDC( hDC ) ;
}
#pragma ENDDUMP