diff options
author | John Ankarström <john@ankarstrom.se> | 2022-02-15 17:17:50 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-02-15 17:17:50 +0100 |
commit | c1eee2b46cd5643ba8efb98b2cd598ef47c4daf6 (patch) | |
tree | cd23129ac6476d5be4814687248e3e71c0d959c9 /c/datalistview.c | |
parent | c605ea0545ac22dc328c83d78011e3d18346eb63 (diff) | |
download | EpisodeBrowser-c1eee2b46cd5643ba8efb98b2cd598ef47c4daf6.tar.gz |
Show data in data list view.
Diffstat (limited to 'c/datalistview.c')
-rw-r--r-- | c/datalistview.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/c/datalistview.c b/c/datalistview.c index 873befc..4a0208d 100644 --- a/c/datalistview.c +++ b/c/datalistview.c @@ -34,9 +34,17 @@ DlvCreate(HWND hWnd) void DlvShowEpisode(int iEpisode) { + HWND hListView; int r; + LVITEM lviKey, lviValue; term_t t; + hListView = GetDlgItem(gDlv_hWnd, IDC_DATALISTVIEW); + ListView_DeleteAllItems(hListView); + + lviKey.mask = LVIF_TEXT; + lviValue.mask = LVIF_TEXT; + t = PL_new_term_refs(3); if(!PL_put_integer(t+0, iEpisode)) return; @@ -56,23 +64,46 @@ DlvShowEpisode(int iEpisode) tHead = PL_new_term_ref(); tList = PL_copy_term_ref(t+2); - while (PL_get_list(tList, tHead, tList)) { + for (int i = 0; PL_get_list(tList, tHead, tList); i++) { atom_t aKey; const char *szKey; char *szValue; + TCHAR *tszKey, *tszValue; term_t tValue; size_t iArity; if (!PL_get_name_arity(tHead, &aKey, &iArity)) continue; szKey = PL_atom_chars(aKey); + if (!szKey) + continue; if (!PL_get_arg(1, tHead, tValue)) continue; if (!PL_get_atom_chars(tValue, &szValue)) continue; - //printf("%s/%d: %s\n", szKey, iArity, szValue); + tszKey = TSZFromSZ(szKey, CP_UTF8); + if (!tszKey) + continue; + tszValue = TSZFromSZ(szValue, CP_UTF8); + if (!tszValue) + continue; + + lviKey.mask = LVIF_TEXT; + lviKey.iItem = i; + lviKey.iSubItem = 0; + lviKey.pszText = tszKey; + lviKey.lParam = iEpisode; + ListView_InsertItem(hListView, &lviKey); + + lviValue.iItem = i; + lviValue.iSubItem = 1; + lviValue.pszText = tszValue; + ListView_SetItem(hListView, &lviValue); + + free(tszKey); + free(tszValue); } } } |