From c6570770bc13bca8fc648913757e35ac5fd6de56 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Wed, 13 Apr 2016 23:58:04 +0000 Subject: [PATCH] Fix signed/unsigned mismatch warning When not using MinGW the value NO_ITEM (-1) is passed as an item count to the macro ListView_ApproximateViewRect. While Windows/Platform SDKs since at least 6.0a cast the argument to (only!) a WPARAM, older ones such as 5.0 don't which results in a signed/unsigned mismatch (converting -1 to WPARAM, which is an UINT_PTR). Fix by always casting to WPARAM when using ListView_ApproximateViewRect. Also use a value of -1 again instead of NO_ITEM because the latter is a bit of a misnomer in this case (as it refers to the total number of items in the control) and to reduce the risk of the cast being removed in the future as well as differentiate it from the MinGW headers issue. Note that this is a different casting problem than with other ListView_XXX macros such as ListView_GetNextItem (which cast to int first and then to WPARAM) where casting to WPARAM results in a warning with WIN64 builds. That situation does not apply to ListView_ApproximateViewRect. Regression since 00c63cfd3a49f06afea595fabeb9fef89a2a03d4. --- src/msw/listctrl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 3c0675eb7b..e37f779da2 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1372,7 +1372,11 @@ void wxListCtrl::AssignImageList(wxImageList *imageList, int which) wxSize wxListCtrl::MSWGetBestViewRect(int x, int y) const { - const DWORD rc = ListView_ApproximateViewRect(GetHwnd(), x, y, NO_ITEM); + // Older Platform SDKs lack a cast to WPARAM inside the + // ListView_ApproximateViewRect macro, so cast -1 to + // WPARAM here to suppress a warning about signed/unsigned mismatch. + const DWORD rc = ListView_ApproximateViewRect(GetHwnd(), x, y, + static_cast(-1)); wxSize size(LOWORD(rc), HIWORD(rc));