Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CListCtrl image not in first column

417 views
Skip to first unread message

Danny Springer

unread,
Dec 30, 2002, 4:27:43 PM12/30/02
to
I have an SDI application based on CListCtrl in reportview. I want my
icons to appear in the third column, after searching a long time I found
the extended style LVS_EX_SUBITEMIMAGES and now I the icon appears in
the column where I want it. There is only one problem left, it also
appears in the first column.

Anyone an idea?
Danny Springer

dsp.vcf

Charles Calvert

unread,
Dec 31, 2002, 5:03:40 PM12/31/02
to
On Mon, 30 Dec 2002 22:27:43 +0100, Danny Springer <d...@knoware.nl>
wrote in <3E10BA4F...@knoware.nl>:

What code are you using to insert the item?


--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research

Danny Springer

unread,
Dec 31, 2002, 7:43:37 PM12/31/02
to

Charles Calvert wrote:

> On Mon, 30 Dec 2002 22:27:43 +0100, Danny Springer <d...@knoware.nl>
> wrote in <3E10BA4F...@knoware.nl>:
>
> >I have an SDI application based on CListCtrl in reportview. I want my
> >icons to appear in the third column, after searching a long time I found
> >the extended style LVS_EX_SUBITEMIMAGES and now I the icon appears in
> >the column where I want it. There is only one problem left, it also
> >appears in the first column.
>
> What code are you using to insert the item?

LV_ITEM lvItem;

// the first column without an icon
lvItem.mask = LVIF_TEXT;
lvItem.iItem = 0;
lvItem.iSubItem = 0;
lvItem.pszText = "Danny";
InsertItem(0, "");
SetItem(&lvItem);

// the second column with an icon
lvItem.mask = LVIF_TEXT|LVIF_IMAGE;
lvItem.iItem = 0;
lvItem.iSubItem = 1;
lvItem.pszText = "Springer";
lvItem.iImage = 0;
SetItem(&lvItem);

// the third column without an icon
lvItem.mask = LVIF_TEXT;
lvItem.iItem = 0;
lvItem.iSubItem = 2;
lvItem.pszText = "15-09-1959";
SetItem(&lvItem);

Other rows are the same (with other text and icons ofcourse). Column 0 always
shows icon 0. Any idea?

Happy new year,
Danny Springer

dsp.vcf

Dave H

unread,
Jan 2, 2003, 11:32:50 AM1/2/03
to
"Danny Springer" <d...@knoware.nl> wrote in message
news:3E1239B8...@knoware.nl...

It sounds like it might be by design : From CListCtrl Overview

Report view
Each item appears on its own line, with additional information arranged in
columns to the right. The leftmost column contains the small icon and label,
and subsequent columns contain subitems as specified by the application. An
embedded header control (class CHeaderCtrl) implements these columns. For
more information on the header control and columns in a report view,
seeUsing CListCtrl: Adding Columns to the Control (Report View).

Pay attention to the second sentence.

dave h

Charles Calvert

unread,
Jan 14, 2003, 1:23:22 PM1/14/03
to
On Wed, 01 Jan 2003 01:43:37 +0100, Danny Springer <d...@knoware.nl>
wrote in <3E1239B8...@knoware.nl>:

>Charles Calvert wrote:
>
>> On Mon, 30 Dec 2002 22:27:43 +0100, Danny Springer <d...@knoware.nl>
>> wrote in <3E10BA4F...@knoware.nl>:
>>
>> >I have an SDI application based on CListCtrl in reportview. I want my
>> >icons to appear in the third column, after searching a long time I found
>> >the extended style LVS_EX_SUBITEMIMAGES and now I the icon appears in
>> >the column where I want it. There is only one problem left, it also
>> >appears in the first column.
>>
>> What code are you using to insert the item?
>
>LV_ITEM lvItem;
>
>// the first column without an icon
>lvItem.mask = LVIF_TEXT;
>lvItem.iItem = 0;
>lvItem.iSubItem = 0;
>lvItem.pszText = "Danny";
>InsertItem(0, "");
>SetItem(&lvItem);

You're not setting lvItem.iImage here. You should either initialize
lvItem using ZeroMemory() or memset() or set each an every member
individually before using it. If you don't, there's no guarantee that
you won't be passing bogus values.

In this case, try setting it to I_IMAGECALLBACK. That will cause the
ListView to treat it as a callback. If your program doesn't handle
the LVN_GETDISPINFO message, then no icon will be drawn for that item.
Note that a blank space the size of an icon will appear, however. I
don't know of a way to eliminate that without doing custom or owner
drawing.

0 new messages