Code:
typedef struct {
HINSTANCE hInstance;
HWND hListView;
char* szNombre;
char* szPC;
} CLIENTESINFO, *LPCLIENTESINFO;
As global:
First calling is from a child dialog proc.
Code:
char nom[128], pc[12];
GetDlgItemText(hDlg, IDC_EDIT1, nom, sizeof(nom)+1);
ci.szNombre = nom;
GetDlgItemText(hDlg, IDC_EDIT2, pc, sizeof(pc)+1);
ci.szPC = pc;
Second call is from the main WinProc:
Code:
char t[12];
int total = ListView_GetItemCount(ci.hListView);
wsprintf(t, "%i", total+1);
InsertItem(ci.hListView, total, 0, t); // t is current position and it shows correctly
InsertItem(ci.hListView, total, 1, ci.szNombre); // empty string
InsertItem prototype:
Code:
void InsertItem(HWND hList, int iItemNo, int iSubNo, char *lpszText) {
LVITEM item = {0};
item.mask = LVIF_TEXT;
item.pszText = lpszText;
item.iItem = iItemNo;
item.iSubItem = iSubNo;
if (iSubNo == 0)
ListView_InsertItem(hList, &item);
else
ListView_SetItem(hList, &item);
return;
}
Now my question is, why the listview always shows a empty string? Isn't the struct global? Thanks