X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dccde0c02375a5f07df76bda78a544f3d0b0fb72..a0e449ff41f55b4d82f108f72638f852c962da2d:/src/msw/listctrl.cpp diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 73a2997bea..52f37500cb 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -68,6 +68,22 @@ #define LVS_OWNERDATA 0x1000 #endif +// mingw32/cygwin don't have declarations for comctl32.dll 4.70+ stuff +#ifndef NM_CACHEHINT + typedef struct tagNMLVCACHEHINT + { + NMHDR hdr; + int iFrom; + int iTo; + } NMLVCACHEHINT; + + #define NM_CACHEHINT NMLVCACHEHINT +#endif + +#ifndef LVN_ODCACHEHINT + #define LVN_ODCACHEHINT (-113) +#endif + // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- @@ -104,6 +120,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT) IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject) @@ -1615,6 +1632,30 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) return TRUE; #endif // _WIN32_IE >= 0x300 + case LVN_ODCACHEHINT: + { + const NM_CACHEHINT *cacheHint = (NM_CACHEHINT *)lParam; + + eventType = wxEVT_COMMAND_LIST_CACHE_HINT; + + // we get some really stupid cache hints like ones for items in + // range 0..0 for an empty control or, after deleting an item, + // for items in invalid range - filter this garbage out + if ( cacheHint->iFrom < cacheHint->iTo ) + { + event.m_oldItemIndex = cacheHint->iFrom; + + long iMax = GetItemCount(); + event.m_itemIndex = cacheHint->iTo < iMax ? cacheHint->iTo + : iMax - 1; + } + else + { + return FALSE; + } + } + break; + case LVN_GETDISPINFO: if ( IsVirtual() ) { @@ -1670,10 +1711,10 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) return TRUE; case LVN_ENDLABELEDIT: - { - *result = event.IsAllowed(); - return TRUE; - } + // logic here is inversed compared to all the other messages + *result = event.IsAllowed(); + + return TRUE; } *result = !event.IsAllowed();