M
Es geht! Vielen Dank an alle noch mal. Und für die die sich auch dafür interessieren (das Design ist vielleich nicht so gut, weil ich mich da noch nicht so auskenne):
Dev-C++: Die „libcomctl32.a“ bei den Projektoptionen einbinden:
#include <windows.h>
#define _WIN32_IE 0x0300
#include <commctrl.h>
HWND hwndListe;
HINSTANCE hThisInstance;
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "Window";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
static HINSTANCE hInstanceList;
static int i, iCol;
static char *szText[3] = {"Field1","Field2", "Field3"};
static int szTextColWidth[3] = {50,50,50};
static LVCOLUMN lvc;
int index;
LV_ITEM lvI;
LV_ITEM lvSI;
... (WinMain usw.)
//List View erstellen:
INITCOMMONCONTROLSEX ictrlex;
ictrlex.dwSize = sizeof(INITCOMMONCONTROLSEX);
ictrlex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&ictrlex);
hwndListe = CreateWindow(WC_LISTVIEW, "",WS_CHILD | WS_BORDER | WS_VISIBLE |
LVS_EDITLABELS | LVS_SORTASCENDING | LVS_REPORT,
5, 5, 150 , 300, hwnd, (HMENU)ID_LISTVIEW, hThisInstance, NULL);
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for (iCol = 0; iCol < 3; iCol++)
{
lvc.iSubItem = iCol+1;
lvc.pszText = szText[iCol];
lvc.cx = szTextColWidth[iCol]; // width of column in pixels
lvc.fmt = LVCFMT_LEFT; // left-aligned column
ListView_InsertColumn(hwndListe, iCol, &lvc);
}
//Daten einfügen, 1. Spalte (items):
// Some code to create the list-view control.
// Initialize LVITEM members that are common to all items.
lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
lvI.state = 0;
lvI.stateMask = 0;
// Initialize LVITEM members that are different for each item.
for (index = 0; index < 3; index++)
{
lvI.iItem = index;
lvI.iImage = index;
lvI.iSubItem = 0;
lvI.pszText = "MMM";
if(ListView_InsertItem(hwndListe, &lvI) == -1)
MessageBox (NULL, "ListView" , "Fehler", 0);
}
lvSI.mask = LVIF_TEXT | LVIF_STATE;
lvSI.state = 0;
lvSI.stateMask = 0;
// Daten einfügen, weiter Spalten (subitems):
for (index = 1; index < 3; index++)
{
lvSI.iItem = 2;
lvSI.iSubItem = index;
lvSI.pszText = "AAaa";
if(ListView_SetItem(hwndListe, &lvSI) == -1)
MessageBox (NULL, "ListView" , "Fehler", 0);
}
//...oder...
//Text einfügen, weiter Spalten (subitems):
ListView_SetItemText(hwndListe, 2 ,2 ,"AA");
:
Falls jemand einen Fehler findet, bitte sofort schreiben.
mfg