Larry
2010-02-13 23:53:58 UTC
Hi,
I am using the following code to create a List View Control:
////////////////////////////////////////////
// Adding List-View Columns
TCHAR szText[256] = {0};
TCHAR szString[5][20] = { TEXT("Column 1"),TEXT("Column 2"),TEXT("Column
3") };
HWND hlistview = CreateWindowEx(0, WC_LISTVIEW, 0, WS_VISIBLE | WS_CHILD |
WS_BORDER | LVS_ALIGNLEFT | LVS_REPORT | LVS_EDITLABELS, 40,90,430,200,
hwnd, (HMENU)IDC_LIST1, hInst, NULL);
SetWindowFont(hlistview,hfont0,TRUE);
LVCOLUMN lvc;
ListView_DeleteAllItems(hlistview);
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for (int k = 0; k < 3; k++)
{
lvc.iSubItem = k;
lvc.cx = 100;
lvc.pszText = szString[k];
lvc.fmt = LVCFMT_LEFT;
ListView_InsertColumn(hlistview, k, &lvc);
}
// Adding List-View Items and Subitems
struct petinfo
{
TCHAR szKind[10];
TCHAR szBreed[50];
TCHAR szPrice[20];
};
petinfo pi[] =
{
{TEXT("Dog"), TEXT("Poodle"), TEXT("$300.00")},
{TEXT("Cat"), TEXT("Siamese"), TEXT("$100.00")},
{TEXT("Fish"), TEXT("Angel Fish"), TEXT("$10.00")}
};
LVITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
lvi.state = 0;
lvi.stateMask = 0;
for (int k = 0; k < 3; k++)
{
lvi.iItem = k;
lvi.iSubItem = 0;
lvi.lParam = (LPARAM) &pi[k];
int res = ListView_InsertItem(hlistview, &lvi);
}
////////////////////////////////////////////////////
while I get the list view collumn correct I don't get any items...what am I
doing wrong?
thanks
I am using the following code to create a List View Control:
////////////////////////////////////////////
// Adding List-View Columns
TCHAR szText[256] = {0};
TCHAR szString[5][20] = { TEXT("Column 1"),TEXT("Column 2"),TEXT("Column
3") };
HWND hlistview = CreateWindowEx(0, WC_LISTVIEW, 0, WS_VISIBLE | WS_CHILD |
WS_BORDER | LVS_ALIGNLEFT | LVS_REPORT | LVS_EDITLABELS, 40,90,430,200,
hwnd, (HMENU)IDC_LIST1, hInst, NULL);
SetWindowFont(hlistview,hfont0,TRUE);
LVCOLUMN lvc;
ListView_DeleteAllItems(hlistview);
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for (int k = 0; k < 3; k++)
{
lvc.iSubItem = k;
lvc.cx = 100;
lvc.pszText = szString[k];
lvc.fmt = LVCFMT_LEFT;
ListView_InsertColumn(hlistview, k, &lvc);
}
// Adding List-View Items and Subitems
struct petinfo
{
TCHAR szKind[10];
TCHAR szBreed[50];
TCHAR szPrice[20];
};
petinfo pi[] =
{
{TEXT("Dog"), TEXT("Poodle"), TEXT("$300.00")},
{TEXT("Cat"), TEXT("Siamese"), TEXT("$100.00")},
{TEXT("Fish"), TEXT("Angel Fish"), TEXT("$10.00")}
};
LVITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
lvi.state = 0;
lvi.stateMask = 0;
for (int k = 0; k < 3; k++)
{
lvi.iItem = k;
lvi.iSubItem = 0;
lvi.lParam = (LPARAM) &pi[k];
int res = ListView_InsertItem(hlistview, &lvi);
}
////////////////////////////////////////////////////
while I get the list view collumn correct I don't get any items...what am I
doing wrong?
thanks