Page 1 of 1

Gdi and Listview

PostPosted: Sat Dec 10, 2016 11:35 am
by Silvio.Falconi
Today I saw this function of My friend Mastintin
here : http://forums.fivetechsupport.com/viewtopic.php?f=6&t=29805&hilit=gdibmp#p168761

the function create the iconl of a image

and I want ask to You if it is possible create or save into a listview control the thumbnail of a file

for a sample if the file is a image it could create a icon of preview of image

for a sample :

the first is a icon of excel
the second is the preview of second file (image)

Image


Now fopr save the image of the file into listview I made:

nImage := Icon_Read(cFile)
nImage := max(0,ILADDICON( oImageList:hImageList, nImage ) )
oItem = TListViewItem():New( oList )
oItem:cText = cFile
oItem:nImage = nImage
oItem:Create()

but I save only the icon of the file

I wish insert this possibilty to make the preview of the image file and the user can see the image immediately

Re: Gdi and Listview

PostPosted: Thu Dec 15, 2016 8:32 am
by Antonio Linares
Silvio,

Nice idea :-)

When you call ILADDICON() you are adding an icon and not a bitmap.

So first, you should convert the icon to a bitmap using FWH function BmpFromIcon()

then instead of calling ILADDICON() you should use

HB_FUNC( ILADD ) // ( HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask )

or

HB_FUNC( ILADDMASKED ) // ( HIMAGELIST himl, HBITMAP hbmImage, COLORREF nClrMask )


I just saw that we could also use this function:

HB_FUNC( ILLOADIMAGE ) // cFileName, nWidth, nImages, nClrTransparent

that seems to do all the work. You may also try it