diff options
Diffstat (limited to 'c')
-rw-r--r-- | c/main.cpp | 27 | ||||
-rw-r--r-- | c/util.h | 7 |
2 files changed, 21 insertions, 13 deletions
@@ -215,7 +215,7 @@ static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPAR Mark m; char* s; if (Pl("cfg","get_limit_screenwriter",&s)) - strcpy_s(g_limitScreenwriter, sizeof(g_limitScreenwriter), s); + Strcpy(g_limitScreenwriter, s); int dlvHeight = 0; Pl("cfg","get_dlv_height",&dlvHeight); @@ -418,18 +418,19 @@ void HandleMainMenu(const HWND hWnd, const WORD command) g_elv->Update(); g_elv->EnsureFocusVisible(); break; - case IDM_VIEW_OTHERS: /* Show/hide other screenwriters. */ - if (g_limitScreenwriter[0]) { + case IDM_VIEW_OTHERS: + if (g_limitScreenwriter[0]) { /* Show episodes by all screenwriters. */ CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_CHECKED); g_limitScreenwriter[0] = 0; - } else { - LVITEM lvi = {LVIF_PARAM, -1}; - if (!g_elv->FindNextItem(&lvi, LVNI_FOCUSED)) break; - + } else { /* Hide episodes by other screenwriters than current. */ + Mark m; char* s; - if (!Pl("episode_data","episode_datum",lvi.lParam,"Screenwriter",&s)) break; - strcpy_s(g_limitScreenwriter, sizeof(g_limitScreenwriter), s); - CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_UNCHECKED); + LVITEM lvi = {LVIF_PARAM, -1}; + if (g_elv->FindNextItem(&lvi, LVNI_FOCUSED) + && Pl("episode_data","episode_datum",lvi.lParam,"Screenwriter",&s)) { + Strcpy(g_limitScreenwriter, s); + CheckMenuItem(GetMenu(hWnd), IDM_VIEW_OTHERS, MF_UNCHECKED); + } } Pl("cfg","set_limit_screenwriter",g_limitScreenwriter); g_elv->Update(); @@ -484,8 +485,7 @@ void HandleContextMenu(const HWND, const WORD command) g_elv->Redraw(); if (cNotFound == 1) { - EBMessageBox(L"Episode could not be opened locally.", - L"Error", MB_ICONWARNING); + EBMessageBox(L"Episode could not be opened locally.", L"Error", MB_ICONWARNING); } else if (cNotFound) { wchar_t msg[64] = {0}; Swprintf(msg, L"%d episodes could not be opened locally.", cNotFound); @@ -504,7 +504,8 @@ void WaitFor(const char* mod, const char* pred) if (activePred) { wchar_t msg[256] = {0}; - Swprintf(msg, L"Another task (%s) is active. " + Swprintf(msg, + L"Another task (%s) is active. " L"Do you want to cancel the existing task and start a new one?", static_cast<wchar_t*>(activePred)); if (EBMessageBox(msg, L"Error", MB_YESNO|MB_ICONWARNING) != IDYES) @@ -10,6 +10,13 @@ inline int Swprintf(wchar_t (&buf)[N], const wchar_t* const fmt, T... xs) return _snwprintf_s(buf, N, _TRUNCATE, fmt, xs...); } +/* Copy to static narrow string buffer. */ +template <size_t N> +inline int Strcpy(char (&dst)[N], const char* const src) +{ + return strcpy_s(dst, N, src); +} + inline int Cmp(const int a, const int b) { if (a == b) return 0; |