From 94119478207034b767c1d0a4fa5d8950f7b07b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 4 Aug 2022 18:18:37 +0200 Subject: Use C++ casts, nullptr. --- c/episodelistview.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'c/episodelistview.cpp') diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index c22b109..3ecaab1 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -12,23 +12,23 @@ #include "win.h" EpisodeListView::EpisodeListView(const HWND hWndParent) - : ListView(hWndParent, (HMENU)IDC_EPISODELISTVIEW, 0) + : ListView(hWndParent, reinterpret_cast(IDC_EPISODELISTVIEW), 0) { LVCOLUMN lvc; lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM; lvc.iSubItem = ELVSIEPISODE; - lvc.pszText = (wchar_t*)L"#"; + lvc.pszText = const_cast(L"#"); lvc.cx = Dpi(42); ListView_InsertColumn(hWnd, ELVSIEPISODE, &lvc); lvc.iSubItem = ELVSITITLE; - lvc.pszText = (wchar_t*)L"Title"; + lvc.pszText = const_cast(L"Title"); lvc.cx = 500; ListView_InsertColumn(hWnd, ELVSITITLE, &lvc); lvc.iSubItem = ELVSIRATING; - lvc.pszText = (wchar_t*)L"/"; + lvc.pszText = const_cast(L"/"); lvc.cx = Dpi(30); ListView_InsertColumn(hWnd, ELVSIRATING, &lvc); @@ -45,7 +45,7 @@ void EpisodeListView::EnsureFocusVisible() LRESULT EpisodeListView::HandleNotify(const LPARAM lParam) { - const NMLISTVIEW* const nm = (NMLISTVIEW*)lParam; + const NMLISTVIEW* const nm = reinterpret_cast(lParam); switch (nm->hdr.code) { case LVN_ITEMCHANGED: /* Select/focus episode. */ @@ -67,7 +67,7 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam) } case LVN_KEYDOWN: /* Navigate episodes by keyboard. */ { - const NMLVKEYDOWN *const nm = (NMLVKEYDOWN*)lParam; + const NMLVKEYDOWN *const nm = reinterpret_cast(lParam); switch (nm->wVKey) { case VK_LEFT: SelectUnwatched(-1); @@ -80,7 +80,7 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam) } case NM_CUSTOMDRAW: /* Make unwatched episodes bold. */ { - const NMLVCUSTOMDRAW* const nm = (NMLVCUSTOMDRAW*)lParam; + const NMLVCUSTOMDRAW* const nm = reinterpret_cast(lParam); switch (nm->nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; @@ -119,7 +119,7 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam) const DWORD pos = GetMessagePos(); Require(TrackPopupMenu(g_hMenuPopup, TPM_RIGHTBUTTON, LOWORD(pos), HIWORD(pos), 0, - m_hWndParent, (const RECT*)NULL)); + m_hWndParent, nullptr)); break; } } @@ -129,7 +129,7 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam) void EpisodeListView::Redraw() { - RedrawWindow(hWnd, NULL, NULL, + RedrawWindow(hWnd, nullptr, nullptr, RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN); } @@ -230,17 +230,17 @@ void EpisodeListView::ShowFocus() void EpisodeListView::Sort() { - ListView_SortItemsEx(hWnd, EpisodeListView::SortProc, (LPARAM)this); + ListView_SortItemsEx(hWnd, EpisodeListView::SortProc, reinterpret_cast(this)); } int CALLBACK EpisodeListView::SortProc(const LPARAM iItem1, const LPARAM iItem2, const LPARAM extra) { - EpisodeListView* const elv = (EpisodeListView*)extra; + EpisodeListView* const elv = reinterpret_cast(extra); - LVITEM lvi1 = {LVIF_PARAM, (int)iItem1}; + LVITEM lvi1 = {LVIF_PARAM, static_cast(iItem1)}; if (!ListView_GetItem(elv->hWnd, &lvi1)) return 0; - LVITEM lvi2 = {LVIF_PARAM, (int)iItem2}; + LVITEM lvi2 = {LVIF_PARAM, static_cast(iItem2)}; if (!ListView_GetItem(elv->hWnd, &lvi2)) return 0; /* abs(m_iSortCol) is the 1-based index of the column to sort by. @@ -395,7 +395,7 @@ void EpisodeListView::Update() extern HWND g_hWndStatus; wchar_t disp[16]; swprintf_s(disp, sizeof(disp)/sizeof(*disp), L"%d", cItem); - SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)disp); + SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), reinterpret_cast(disp)); SendMessage(hWnd, WM_SETREDRAW, TRUE, 0); } @@ -411,7 +411,7 @@ void EpisodeListView::UpdateItem(const int iItem, const LPARAM lParam) r: int rating; if (!Pl("episode_data","episode_rating",lParam,&rating)) { - ListView_SetItemText(hWnd, iItem, ELVSIRATING, (wchar_t*)L""); + ListView_SetItemText(hWnd, iItem, ELVSIRATING, const_cast(L"")); return; } @@ -432,8 +432,8 @@ LRESULT CALLBACK EpisodeListView::WndProc(const HWND hWnd, const UINT uMsg, * handled by the NM_RETURN case in HandleNotify. */ const LRESULT lResult = CallWindowProc(m_proc0, hWnd, uMsg, wParam, lParam); - if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN - && ((MSG*)lParam)->wParam == VK_RETURN) + MSG* const msg = reinterpret_cast(lParam); + if (lParam && msg->message == WM_KEYDOWN && msg->wParam == VK_RETURN) return DLGC_WANTMESSAGE; return lResult; } -- cgit v1.2.3