Bonjour, jai creer une listview comme suit:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Create the list view window that starts out in report view
		// and allows label editing.
		hWndList = CreateWindowEx(0L,
			WC_LISTVIEW,                // list view class
			"",                         // no default text
			WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT | WS_EX_CLIENTEDGE,
			30, 75,
			260, 300,
			hWnd,
			(HMENU)ID_LISTVIEW,
			NULL,
			NULL);
 
 
		ListView_SetExtendedListViewStyleEx(hWndList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
 
		LV_COLUMN lvC;      // List View Column structure
		char szText[MAX_PATH];    // Place to store some text
 
		lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lvC.fmt = LVCFMT_LEFT;  // left align the column
 
		lvC.cx = 75;// width of the column, in pixels
		lvC.pszText = "colonneA";
		ListView_InsertColumn(hWndList, 0, &lvC);
 
		lvC.pszText = "colonneB";
		ListView_InsertColumn(hWndList, 1, &lvC);
 
		lvC.pszText = "colonneC";
		ListView_InsertColumn(hWndList, 2, &lvC);
 
		lvC.pszText = "colonneD";
		ListView_InsertColumn(hWndList, 3, &lvC);
 
		lvC.pszText = "colonneE";
		ListView_InsertColumn(hWndList, 4, &lvC);
 
 
		// load a random item in memory
		ListViewDATA[0].colonneA = 2;
		ListViewDATA[0].colonneB = 5673920485;
		ListViewDATA[0].colonneC = 50;
		ListViewDATA[0].colonneD = 456789;
		ListViewDATA[0].colonneE = 345;
 
		int iSubItem;
		LV_ITEM lvI;
		lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
		lvI.state = 0;
		lvI.stateMask = 0;
		lvI.iItem = 0;
		lvI.iSubItem = 0;
 
		lvI.pszText = LPSTR_TEXTCALLBACK;
		lvI.cchTextMax = 64;
		lvI.lParam = (LPARAM)&ListViewDATA[0];
 
		ListView_InsertItem(hWndList, &lvI);
		for (iSubItem = 1; iSubItem < 5; iSubItem++)
		{
			ListView_SetItemText(hWndList,
				0,// = lvI.iItem
				iSubItem,
				LPSTR_TEXTCALLBACK);
		}
et la gere avec le msg WM_NOTIFY comme ceci:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
case WM_NOTIFY:
	{
		LV_DISPINFO *pLvdi = (LV_DISPINFO *)lParam;
		NM_LISTVIEW *pNm = (NM_LISTVIEW *)lParam;
		LISTVIEWSTRUCT *pListviewdata = (LISTVIEWSTRUCT *)(pLvdi->item.lParam);
		static TCHAR szText[10];
 
		if (wParam == ID_LISTVIEW)
		{
			switch (pLvdi->hdr.code)
			{
			case LVN_GETDISPINFO:
				switch (pLvdi->item.iSubItem)
				{
				case 0:
					sprintf(szText, "%u", pListviewdata->colonneA);
					pLvdi->item.pszText = szText;
					break;
 
				case 1:
					sprintf(szText, "%u", pListviewdata->colonneB);
					pLvdi->item.pszText = szText;
					break;
 
				case 2:
					sprintf(szText, "%u", pListviewdata->colonneC);
					pLvdi->item.pszText = szText;
					break;
 
				case 3:
					sprintf(szText, "%u", pListviewdata->colonneD);
					pLvdi->item.pszText = szText;
					break;
 
				case 4:
					sprintf(szText, "%u", pListviewdata->colonneE);
					pLvdi->item.pszText = szText;
					break;
 
				default:
					break;
				}
				break;
 
			default:
				break;
			}
 
		}
	}
	break;


la listview saffiche correctement mais il mest impossible de selectionner une ligne, meme en utilisant "ListView_SetItemState".
Comment faire ?

merci davance