Really get rid of warnings in casts to WPARAM in wxMSW wxListCtrl
Finally really fix the problem with an explicit cast to WPARAM needed to fix the warning for MinGW but provoking a warning with MSVC: this cast was added in612bbde52f
, reverted in77cfdec054
and added back in36e5a9a7c4
and so we were back to having warnings in MSVC 64 bit builds. Work around them by defining NO_ITEM constant differently for MinGW and MSVC to satisfy both of them.
This commit is contained in:
@@ -54,6 +54,18 @@
|
|||||||
#define NMLVFINDITEM NM_FINDITEM
|
#define NMLVFINDITEM NM_FINDITEM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// MinGW headers lack casts to WPARAM inside several ListView_XXX() macros, so
|
||||||
|
// add them to suppress the warnings about implicit conversions/truncation.
|
||||||
|
// However do not add them for MSVC as it has casts not only to WPARAM but
|
||||||
|
// actually to int first, and then to WPARAM, and casting to WPARAM here would
|
||||||
|
// result in warnings when casting 64 bit WPARAM to 32 bit int inside the
|
||||||
|
// macros in Win64 builds.
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#define NO_ITEM (static_cast<WPARAM>(-1))
|
||||||
|
#else
|
||||||
|
#define NO_ITEM (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1337,10 +1349,7 @@ void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
|
|||||||
|
|
||||||
wxSize wxListCtrl::MSWGetBestViewRect(int x, int y) const
|
wxSize wxListCtrl::MSWGetBestViewRect(int x, int y) const
|
||||||
{
|
{
|
||||||
// The cast is necessary to suppress a MinGW warning due to a missing cast
|
const DWORD rc = ListView_ApproximateViewRect(GetHwnd(), x, y, NO_ITEM);
|
||||||
// to WPARAM in the definition of ListView_ApproximateViewRect() in its
|
|
||||||
// own headers (this was the case up to at least MinGW 4.8).
|
|
||||||
const DWORD rc = ListView_ApproximateViewRect(GetHwnd(), x, y, (WPARAM)-1);
|
|
||||||
|
|
||||||
wxSize size(LOWORD(rc), HIWORD(rc));
|
wxSize size(LOWORD(rc), HIWORD(rc));
|
||||||
|
|
||||||
@@ -2738,12 +2747,8 @@ static void HandleItemPaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// same thing for CDIS_FOCUS (except simpler as there is only one of them)
|
// same thing for CDIS_FOCUS (except simpler as there is only one of them)
|
||||||
//
|
|
||||||
// NB: cast is needed to work around the bug in mingw32 headers which don't
|
|
||||||
// have it inside ListView_GetNextItem() itself (unlike SDK ones)
|
|
||||||
if ( ::GetFocus() == hwndList &&
|
if ( ::GetFocus() == hwndList &&
|
||||||
ListView_GetNextItem(
|
ListView_GetNextItem(hwndList, NO_ITEM, LVNI_FOCUSED) == item )
|
||||||
hwndList, static_cast<WPARAM>(-1), LVNI_FOCUSED) == item )
|
|
||||||
{
|
{
|
||||||
nmcd.uItemState |= CDIS_FOCUS;
|
nmcd.uItemState |= CDIS_FOCUS;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user