Page 1 of 1

load *.RES into Imagelist() ?

PostPosted: Mon Dec 12, 2022 8:52 am
by Jimmy
hi,

i just get stuck to load *.RES into ImageList.

i can load Resource from File into Imagelist() and also Image when have hBitmap / hIcon
under Xbase++ i can use LoadResource() but need to assign it to Object to get hBitmap / hIcon

how under Fivewin :?:

Re: load *.RES into Imagelist() ?

PostPosted: Mon Dec 12, 2022 9:08 am
by Enrico Maria Giordano
Please search for *.prg containing TImageList inside the FWH samples folder.

Re: load *.RES into Imagelist() ?

PostPosted: Wed Dec 14, 2022 11:20 pm
by Jimmy
hi Enrico,

i have to specify my Question :
how to "load" Bitmap Resource into Imagelist() :?:

---

CLASS TImageList have

Code: Select all  Expand view
  if ValType( oIcon ) == "C"
      if File( oIcon )
         DEFINE ICON oIco FILENAME oIcon
      else
         DEFINE ICON oIco RESOURCE oIcon
      endif
   else
      oIco = oIcon
   endif 

but how when using Bitmap :?:
Code: Select all  Expand view
DEFINE BITMAP oBmpImage RESOURCE cString
// how about oBmpMask ?
Add( oBmpImage, oBmpMask )

Re: load *.RES into Imagelist() ?

PostPosted: Thu Dec 15, 2022 10:43 am
by Antonio Linares
Dear Jimmy,

You have an example of use in FWH\samples\fivedit.prg
Code: Select all  Expand view
  ::oImageListL = TImageList():New()
   ::oImageListL:Add( oBmp1 := TBitmap():Define( "folder",,  ::oWnd ),;
                      oBmp2 := TBitmap():Define( "fldmask",, ::oWnd ) )

Re: load *.RES into Imagelist() ?

PostPosted: Thu Dec 15, 2022 1:49 pm
by Jimmy
hi Antonio,

thx for Answer.
i got it work but Result look different
ICON
Image
Bitmap
Image
Code: Select all  Expand view
#ifdef Use_Icon
         iImage_0 := oGrid:oImageListSmall:AddIcon( acIcon[ ii ] )
         iImage := MAX( 0, oGrid:oImageListBig:AddIcon( acIcon[ ii ] ) )
#else
         iImage_0 := oGrid:oImageListSmall:Add( oBmp1 := TBitmap():Define( acBitmaps[ ii ],, oDlg ),;
                                                oBmp2 := TBitmap():Define( acBitmaps[ ii ],, oDlg ) )
         iImage := MAX( 0, oGrid:oImageListBig:Add( oBmp1 := TBitmap():Define( acBitmaps[ ii ],, oDlg ),;
                                                    oBmp2 := TBitmap():Define( acBitmaps[ ii ],, oDlg ) ) )
#endif

         LV_ADDITEMS( oGrid:hLv, aItem, iImage )

#ifdef Use_Icon
         DestroyIcon( iImage_0 )
         DestroyIcon( iImage )
#else
         DeleteObject( iImage_0 )
         DeleteObject( iImage )

         DeleteObject( oBmp1 )
         DeleteObject( oBmp2 )
#endif

what i´m doing wrong :?:

Re: load *.RES into Imagelist() ?

PostPosted: Thu Dec 15, 2022 2:56 pm
by Antonio Linares
Dear Jimmy,

Are you properly providing it a masked bitmap for each one ?

Re: load *.RES into Imagelist() ?

PostPosted: Thu Dec 15, 2022 3:05 pm
by Jimmy
hi Antonio,
Antonio Linares wrote:Are you properly providing it a masked bitmap for each one ?

i do not know what "masked bitmap" mean ...
"just" have try to use your Sample which use different Bitmap ("folder" / "fldmask")

did i "clean up" wrong as it "seems" all use 1st Bitmap :?:

Re: load *.RES into Imagelist() ?

PostPosted: Thu Dec 15, 2022 3:08 pm
by Antonio Linares
Dear Jimmy,

Please review FWH\samples\fldmask.bmp to see what the mask bitmap must contain

Anyhow I don't know why it is repeating it...

Re: load *.RES into Imagelist() ?

PostPosted: Sun Dec 18, 2022 3:53 pm
by Jimmy
hi,

i found Solution but not sure "why" ... hm

for my TGrid() i use 2 x ImageList() for "Small" / "Big" like Explorer
Imagelsit() for "Big" are only used in "LVS_ICON" Mode but not for "LVS_REPORT" Mode which i use here

now when NOT add Bitmap to "Big" Imagelist() only to "Small" Imagelist() it display right :D
it might be "Size" of "Big" which i have SET to 256 (normal 32)

Re: load *.RES into Imagelist() ?

PostPosted: Mon Dec 19, 2022 7:30 am
by Antonio Linares
very good!

thanks for sharing it :-)