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 00c63cfd3a
.
This commit is contained in:
@@ -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<WPARAM>(-1));
|
||||
|
||||
wxSize size(LOWORD(rc), HIWORD(rc));
|
||||
|
||||
|
Reference in New Issue
Block a user