P
Hiermit machst du einen Listview mit zwei Spalten auf, die erste Spalte hatt noch Icons vorangestellt.
hLstBox_01 = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, "",
WS_CHILD | WS_BORDER | WS_VISIBLE |
WS_VSCROLL | LVS_REPORT | LVS_NOLABELWRAP |
LVS_SINGLESEL | LVS_ICON | LVS_EDITLABELS,
1,1,
(MainXsize-10),(MainYsize-50)/*400*/,
hWnd,NULL,hInst,0);
hImage = ImageList_Create(32, 32, ILC_COLOR8 | ILC_MASK, 1, 1);
hSmall = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 1);
ImageList_AddIcon(hSmall, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_NONE)));
ImageList_AddIcon(hSmall, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_PRINTF)));
ImageList_AddIcon(hSmall, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_ERROR)));
ImageList_AddIcon(hSmall, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_DEBUG)));
ImageList_AddIcon(hSmall, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_UNKNOWN)));
ListView_SetImageList(hLstBox_01, hImage, LVSIL_NORMAL);
ListView_SetImageList(hLstBox_01, hSmall, LVSIL_SMALL);
//Spalte 1
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_IMAGE;//LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
col.fmt=LVCFMT_LEFT | LVCFMT_COL_HAS_IMAGES ;//LVCFMT_LEFT;
col.pszText = (char*)"Spalte 1";
col.cx =(int)(200);
col.iSubItem = 1;
col.cchTextMax = NORMSTRINGLEN;
col.iImage = -1;
ListView_InsertColumn (hLstBox_01,1,&col);
//Spalte 2
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
col.fmt=LVCFMT_LEFT;
col.pszText = (char*)"Spalte 2";
col.cx =(int)(200);
col.iSubItem = 2;
ListView_InsertColumn (hLstBox_01,2,&col);
ShowWindow(hLstBox_01, nCmdShow);
UpdateWindow(hLstBox_01);
item.mask = LVIF_TEXT;
item.iItem = ListView_GetItemCount(hLstBox_01);
item.iSubItem = 0;
return TRUE;
}
Hiermit trägst du eine neue Zeile ein
item.iImage = ICON_UNKNOWN; // Icon das benutzt werden soll
item.pszText = TextDerAusgegeben werden soll;
item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
item.state = LVIS_FOCUSED|LVIS_SELECTED;
item.iSubItem = 0;
ListView_InsertItem(hLstBox_01,&item);
ListView_Scroll( hLstBox_01, 0, 10);
item.iItem++;
UpdateWindow(hLstBox_01);