-
July 23rd, 2015, 07:29 AM
#1
[RESOLVED] Need help displaying subitem text in listview control in Tile view
I have been struggling with this for a while now and can't seem to get subitem text to appear in a listview control in tile view mode. I do have visual styles enabled. If anyone could take a look at my code and give me a hand with this i would be obliged! This code works fine for any other view, I am able to insert columns, items, and set subitem text no problem.
Create the listview
Code:
DWORD style = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | LVS_SHAREIMAGELISTS;
DWORD exstyle = LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP;
hwnd = CreateWindowEx(
0,
WC_LISTVIEW,
NULL,
style,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
parent,
NULL,
GetModuleHandle(NULL),
NULL);
SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)exstyle);
Set tile view
Code:
SendMessage(hwnd, LVM_SETVIEW, (WPARAM)LV_VIEW_TILE, 0);
LVTILEVIEWINFO tvi = {0};
tvi.cbSize = sizeof(LVTILEVIEWINFO);
tvi.dwMask = LVTVIM_COLUMNS;
tvi.cLines = 2; // 2 subitems
SendMessage(hwnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)&tvi);
Insert items
Code:
// Uncommenting code works fine but still no subitem text appears
// INT colfmt[2] = { LVCFMT_LEFT, LVCFMT_LEFT };
// UINT order[2];
LVITEM lvi = {0};
lvi.mask = LVIF_TEXT | LVIF_IMAGE | (group >= 0? LVIF_GROUPID: 0) | LVIF_PARAM; // LVIF_COLUMNS | LVIF_COLFMT
lvi.iItem = index;
lvi.iImage = image;
lvi.pszText = buffer;
lvi.lParam = param;
lvi.iGroupId = group;
// lvi.cColumns = 2;
// lvi.piColFmt = colfmt;
// lvi.puColumns = order;
INT ret = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM)&lvi);
Add columns
Code:
// Commented code doesn't seem to have any effect
LVCOLUMN lvc = {0};
lvc.mask = LVCF_TEXT | (image >= 0? LVCF_IMAGE: 0) | LVCF_WIDTH; // LVCF_SUBITEM;
lvc.pszText = buffer;
lvc.cx = width;
lvc.iImage = image;
// lvc.iSubItem = subitem;
INT ret = SendMessage(hwnd, LVM_INSERTCOLUMN, (WPARAM)index, (LPARAM)&lvc);
Set subitem text
Code:
LVITEM lvi = {0};
lvi.mask = LVIF_TEXT;
lvi.iItem = index;
lvi.iSubItem = subitem; // <-- nothing happens whether I add columns first or not
lvi.pszText = buffer;
SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&lvi);
-
July 23rd, 2015, 08:49 AM
#2
Re: Need help displaying subitem text in listview control in Tile view
Victor Nijegorodov
-
July 23rd, 2015, 09:28 AM
#3
Re: Need help displaying subitem text in listview control in Tile view
Thanks very much, that helped me solve this! I was using the puColumns member improperly when inserting items.
Last edited by falcon60; July 23rd, 2015 at 09:37 AM.
-
July 27th, 2015, 07:18 AM
#4
Re: [RESOLVED] Need help displaying subitem text in listview control in Tile view
columns -> report view
you're using tile view.
-
July 28th, 2015, 06:53 AM
#5
Re: [RESOLVED] Need help displaying subitem text in listview control in Tile view
Originally Posted by OReubens
columns -> report view
you're using tile view.
If I don't insert columns it doesn't display subitems in tile view. Only in report view columns are actually visible.
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
|