Ciao a tutti,
devo inserire i campi di un file txt con delimitatore in una listview.
Il cocice che uso é:
La funzione InsertRow ha i parametri del tipo *char:codice:int GetItems() { char buf[BUFSIZ]; int i=0; string strRem; string strCombo1; string strDate; string strTime; string strStatus; if ((fp = fopen("file.txt", "r")) == NULL) { perror ("file.txt"); return (EXIT_FAILURE); } ifstream file ( "file.txt" ); // declare file stream: http://www.cplusplus.com/reference/iostream/ifstream/ string value; while (fgets(buf, sizeof(buf), fp) != NULL) { while ( file.good() ) { for (int i=0 ; i<5 ; i++) { getline ( file, value, '|'); strRem=string( value, 0, value.length()); strCombo1=string( value, 0, value.length()); strDate=string( value, 0, value.length()); strTime=string( value, 0, value.length()); strStatus=string( value, 0, value.length()); } } InsertRow(hWndListView,strRem,strCombo1,strDate ,strTime,strStatus); i++; } return(0); }
Tutto funziona bene fino a quando non cerco di inserire i campi nella listview. Ho fatto delle ricerche ma purtroppo il compilatore non mi accetta la conversione da string a *char.codice:void InsertRow (const HWND hWnd, char *col1, char *col2, char *col3, char *col4,char *col5) { LV_ITEM lvItem; lvItem.mask = 0; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.iItem = ListView_InsertItem (hWnd, &lvItem); lvItem.mask = LVIF_TEXT; lvItem.pszText = col1; lvItem.cchTextMax = strlen (lvItem.pszText); ListView_SetItem (hWnd, &lvItem); lvItem.iSubItem = 1; lvItem.pszText = col2; lvItem.cchTextMax = strlen (lvItem.pszText); ListView_SetItem (hWnd, &lvItem); lvItem.iSubItem = 2; lvItem.pszText = col3; lvItem.cchTextMax = strlen (lvItem.pszText); ListView_SetItem (hWnd, &lvItem); lvItem.iSubItem = 3; lvItem.pszText = col4; lvItem.cchTextMax = strlen (lvItem.pszText); ListView_SetItem (hWnd, &lvItem); lvItem.iSubItem = 4; lvItem.pszText = col5; lvItem.cchTextMax = strlen (lvItem.pszText); ListView_SetItem (hWnd, &lvItem); }
Come posso risolvere?
Grazie.

Rispondi quotando