diff options
author | John Ankarström <john@ankarstrom.se> | 2022-04-07 10:25:50 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-04-07 10:25:50 +0200 |
commit | 85add87933a1cb5a47049b87fbb224448385afae (patch) | |
tree | e014c897e9e2d783b9ff2e20598c2d356591c98e /c/episodelistview.c | |
parent | aa967ecb490fea1e298b7cb7bf8d425539f45043 (diff) | |
download | EpisodeBrowser-85add87933a1cb5a47049b87fbb224448385afae.tar.gz |
Add status bar.
Diffstat (limited to 'c/episodelistview.c')
-rw-r--r-- | c/episodelistview.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/c/episodelistview.c b/c/episodelistview.c index f533d4f..14fc6b9 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -170,7 +170,9 @@ ElvUpdate() LVITEM lvi, lviEpisode, lviTop; LVFINDINFO lvfi; term_t t; - static int rgEpSel[2048]; + extern HWND HWndStatus; + static TCHAR tszDisp[16], tszEpisode[16], tszTotal[16]; + static int aEpSel[2048]; lviEpisode.mask = LVIF_TEXT|LVIF_PARAM; @@ -187,9 +189,9 @@ ElvUpdate() HElv, lvi.iItem, LVNI_SELECTED)) != -1 && i < 2048) { if (!ListView_GetItem(HElv, &lvi)) continue; - rgEpSel[i++] = lvi.lParam; + aEpSel[i++] = lvi.lParam; } - rgEpSel[i] = 0; + aEpSel[i] = 0; /* Save focus. */ iEpFocus = 0; @@ -208,8 +210,6 @@ ElvUpdate() GI(t,&cEp) return; for (iEp = 1, iItem = 0; iEp <= cEp; iEp++) { - int cb; - TCHAR *tszEpisode; extern int BViewTVOriginal, BViewWatched; if (!BViewWatched) { @@ -229,10 +229,7 @@ ElvUpdate() } /* Format episode number string. */ - ep: cb = 100; - tszEpisode = malloc(cb*sizeof(TCHAR)); - if (!tszEpisode) continue; - _stprintf_s(tszEpisode, cb, TEXT("%d"), iEp); + ep: _stprintf_s(tszEpisode, sizeof(tszEpisode), TEXT("%d"), iEp); /* Insert item. */ lviEpisode.iItem = iItem++; @@ -241,8 +238,6 @@ ElvUpdate() lviEpisode.lParam = iEp; ListView_InsertItem(HElv, &lviEpisode); ElvUpdateItem(&lviEpisode); - - free(tszEpisode); } lvfi.flags = LVFI_PARAM; @@ -257,9 +252,9 @@ ElvUpdate() ElvSetTop(iItemTopNew); /* Reset selection. */ - for (i = 0; rgEpSel[i]; i++) { + for (i = 0; aEpSel[i]; i++) { int iSel; - lvfi.lParam = rgEpSel[i]; + lvfi.lParam = aEpSel[i]; if ((iSel = ListView_FindItem(HElv, -1, &lvfi)) != -1) ListView_SetItemState(HElv, iSel, LVIS_SELECTED, LVIS_SELECTED); @@ -278,6 +273,10 @@ ElvUpdate() LVIS_FOCUSED, LVIS_FOCUSED); } + _stprintf_s(tszDisp, sizeof(tszDisp), TEXT("%d"), iItem); + SendMessage(HWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)tszDisp); + _stprintf_s(tszTotal, sizeof(tszTotal), TEXT("%d"), cEp); + SendMessage(HWndStatus, SB_SETTEXT, MAKEWPARAM(2,0), (LPARAM)tszTotal); SendMessage(HElv, WM_SETREDRAW, TRUE, 0); ElvRedraw(); } |