Click to See Complete Forum and Search --> : Displaying Jpg in Listview


Mortis
April 26th, 2003, 10:40 AM
I'm trying to make a list of thumbnails in a listview window. So far I can only make it work with resource bitmaps, when i try a hard coded jpg, i get get a blank image, with "hiya" under it
Its probally something really dumb, but i just cant find it. If anyone could point it out i'd be very grateful
(I'm almost positive its not the Bmp variable, the function does return a BITMAP)

//Here's the code

//Opens a thumbnail struc and sets its x and y
thumb = openThumb(&x ,&y);
_bstr_t txt("Hiya");

//Gets Handle to the listControl
hThumbList = GetDlgItem(g_hWnd ,IDC_LIST_THUMB);

//x = 160, y = 120
hImageList = ImageList_Create(x,y,ILC_MASK | ILC_COLOR32,0,0);

Bmp = getThumbBmp(g_hWnd,hPicDC); //Returns a HBITMAP

//Adds bitmap to the list as position 0
ImageList_Add(hImageList, Bmp, NULL);


SendDlgItemMessage(g_hWnd,IDC_LIST_THUMB,LVM_SETIMAGELIST,0,(LPARAM)hImageList);

lvi.mask = TVIF_TEXT | TVIF_IMAGE;
lvi.pszText = txt;
lvi.iImage = 0; //First Image added
// Insert info to the Listview
SendMessage(hThumbList ,LVM_INSERTITEM,0,(LPARAM)&lvi);

Bengi
April 27th, 2003, 03:00 AM
this works for me:

char url[]="C:\\a.jpg";
LVBKIMAGE plvbki;

memset(&plvbki,0,sizeof(plvbki));
plvbki.ulFlags=LVBKIF_SOURCE_URL;
plvbki.pszImage=url;
plvbki.xOffsetPercent=40;
plvbki.yOffsetPercent=15;
OleInitialize(NULL);

SendMessage(hList,LVM_SETTEXTBKCOLOR, 0,(LPARAM)CLR_NONE);
SendMessage(hList,LVM_SETBKIMAGE,0,(LPARAM)(LPLVBKIMAGE)&plvbki);


note, m$ didn't added any option to use resoruce loading so only external url will do the job.

Mortis
April 27th, 2003, 06:23 AM
thanks dude
its workin grand now

Bengi
April 27th, 2003, 11:37 AM
no prob man.