|
-
March 29th, 1999, 05:06 AM
#1
Listview control - Please help me !!!
Question on listview control:
In my superclassed listview control I use images in some
of the list items. These have transparent backgrounds.
However, when I select a row, the transparent background is not
selected, it is still the background colour of the control.
How can I tell the control to select the transparent
background of the control as well?
Is this ownerdrawn stuff?
Thanks,
Charles Gamble.
-
March 29th, 1999, 07:49 AM
#2
Re: Listview control - Please help me !!!
Did you specify a mask when you created the ImageList? (ILC_MASK)
-
March 29th, 1999, 09:20 AM
#3
Re: Listview control - Please help me !!!
Here's the code where I create the imagelist and add it to the control:
// Create and initialize image list used with control
hImageList = ImageList_Create(16,16,ILC_COLORDDB|ILC_MASK,14,1);
hBitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_IMAGELIST));
// Add images to image list
ImageList_AddMasked(hImageList,hBitmap,RGB(0,255,255));
DeleteObject(hBitmap);
ImageList_SetBkColor(hImageList, CLR_NONE);
// Set image list of list view
SendMessage(LVM_SETIMAGELIST,(WPARAM)LVSIL_SMALL, (LPARAM)hImageList);
Any ideas?
Charles.
-
March 29th, 1999, 02:13 PM
#4
Re: Listview control - Please help me !!!
That looks right. The only thing I do differently is pass white (RGB(255,255,255)) to AddMasked.
-
March 30th, 1999, 03:43 AM
#5
Re: Listview control - Please help me !!!
I have enclosed some more code which describes how I add two of my columns
to the listview control. I am using ATL 3.0, but the principles are the same.
LVCOLUMN colDetails;
colDetails.mask = LVCF_WIDTH;
colDetails.cx = 30;
SendMessage(LVM_INSERTCOLUMN,nColumnIndex,(LPARAM)&colDetails);
nPriorityIndex = nColumnIndex;
nColumnIndex++;
SendMessage(LVM_INSERTCOLUMN,nColumnIndex,(LPARAM)&colDetails);
nStatusIndex = nColumnIndex;
nColumnIndex++;
--------(The image list is created here, using the code I sent previously)
// Get listview header
hHeader = ListView_GetHeader(m_hWndCD);
HDITEM hd;
hd.mask = HDI_FORMAT|HDI_LPARAM|HDI_IMAGE;
hd.fmt = HDF_LEFT|HDF_IMAGE;
hd.iImage = 0;
hd.lParam = ePriority;
// Set header images and LPARAM information (used to identify columns)
SendMessage(hHeader, HDM_SETITEM, nPriorityIndex, (LPARAM)&hd);
hd.iImage = 1;
hd.lParam = eStatus;
SendMessage(hHeader, HDM_SETITEM, nStatusIndex, (LPARAM)&hd);
I have my own function which selects the listview items as I want to send
events back to the container when items are selected. Below is the selecting
part of it:
// Deselect currently selected item
lvItem.state = 0;
int i = SendMessage(LVM_SETITEMSTATE, (WPARAM)-1,
(LPARAM)&lvItem);
// Select new item
lvItem.state = LVIS_SELECTED;
i = SendMessage(LVM_SETITEMSTATE, (WPARAM)HitTestInf.iItem,
(LPARAM)&lvItem);
So my main problems are that the transparent backgrounds of images are not
being highlighted when an item is selected. Also, when an image is set in the header control, there must be an image in
the column contents or else a blank space is left.
Here is the code where I add items:
// Insert item into list
lvItem.mask = LVIF_PARAM;
lvItem.iItem = SendMessage(LVM_GETITEMCOUNT, 0, 0);
lvItem.iSubItem = 0;
lvItem.lParam = (LPARAM)ActivityDetails;
SendMessage(LVM_INSERTITEM,(WPARAM)0,(LPARAM)&lvItem);
// Add Priority information
// Assign mask to text and image here, otherwise the image
// from the column header is displayed in the row
lvItem.mask = LVIF_TEXT|LVIF_IMAGE;
lvItem.iSubItem = 0
lvItem.pszText = OLE2T(bsPriority);
lvItem.cchTextMax = _tcslen(lvItem.pszText);
SendMessage(LVM_SETITEM,(WPARAM)0,(LPARAM)&lvItem);
// Add Status information
lvItem.mask = LVIF_IMAGE;
lvItem.iSubItem = 1;
lvItem.iImage = 4
SendMessage(LVM_SETITEM,0,(LPARAM)&lvItem);
Any ideas?
Are you having these problems? If not, maybe you could send me some of your
code?
Thanks for the help anyway.
Charles.
-
April 1st, 1999, 08:34 PM
#6
Re: Listview control - Please help me !!!
If you were using OWNER_DRAWn listview ctrl you could specify ILD_TRANSPARENT flag when drawing icon image yourself:
CImageList *pImageList = listView.GetImageList(LVSIL_SMALL);
if(pImageList) {
POINT pt;
pt.x = lpDrawItem->rcItem.left;
pt.y = lpDrawItem->rcItem.top;
pImageList->Draw(&dc, lvi.iImage, pt, ILD_TRANSPARENT);
}
-
May 11th, 2001, 01:14 AM
#7
Re: Listview control - Please help me !!!
check out with the ILD_TRANSPARENT style
make use of ImageList_DrawEx()function in which
u can set this style
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|