]> git.saurik.com Git - wxWidgets.git/commitdiff
fill in the fields of wxListItem in a wxListEvent before handling the event (closes...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 24 May 2009 18:04:37 +0000 (18:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 24 May 2009 18:04:37 +0000 (18:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/listbase.h
src/msw/listctrl.cpp

index ef32584e180ba3980a9153e91a9330ebc40004b9..df07401a0e319f6e8027d64ed7abdef33d9639d8 100644 (file)
@@ -380,10 +380,10 @@ class WXDLLIMPEXP_CORE wxListEvent : public wxNotifyEvent
 public:
     wxListEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
         : wxNotifyEvent(commandType, winid)
 public:
     wxListEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
         : wxNotifyEvent(commandType, winid)
-        , m_code(0)
-        , m_oldItemIndex(0)
-        , m_itemIndex(0)
-        , m_col(0)
+        , m_code(-1)
+        , m_oldItemIndex(-1)
+        , m_itemIndex(-1)
+        , m_col(-1)
         , m_pointDrag()
         , m_item()
         , m_editCancelled(false)
         , m_pointDrag()
         , m_item()
         , m_editCancelled(false)
index d3ec4279ed54190dd19359c9cf9e9c2ca1c30612..615d64f8b5a27a533be2197773ba38a403ccad68 100644 (file)
@@ -2367,13 +2367,18 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                 wxZeroMemory(lvhti);
 
 #if defined(__WXWINCE__) && !defined(__HANDHELDPC__) && _WIN32_WCE < 400
                 wxZeroMemory(lvhti);
 
 #if defined(__WXWINCE__) && !defined(__HANDHELDPC__) && _WIN32_WCE < 400
-              if(nmhdr->code == GN_CONTEXTMENU) {
-                  lvhti.pt = ((NMRGINFO*)nmhdr)->ptAction;
-              } else
+                if ( nmhdr->code == GN_CONTEXTMENU )
+                {
+                    lvhti.pt = ((NMRGINFO*)nmhdr)->ptAction;
+                }
+                else
 #endif //__WXWINCE__
 #endif //__WXWINCE__
-                ::GetCursorPos(&(lvhti.pt));
-                ::ScreenToClient(GetHwnd(),&(lvhti.pt));
-                if ( ListView_HitTest(GetHwnd(),&lvhti) != -1 )
+                {
+                    ::GetCursorPos(&(lvhti.pt));
+                }
+
+                ::ScreenToClient(GetHwnd(), &lvhti.pt);
+                if ( ListView_HitTest(GetHwnd(), &lvhti) != -1 )
                 {
                     if ( lvhti.flags & LVHT_ONITEM )
                     {
                 {
                     if ( lvhti.flags & LVHT_ONITEM )
                     {
@@ -2537,6 +2542,17 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
 
     event.SetEventType(eventType);
 
 
     event.SetEventType(eventType);
 
+    // fill in the item before passing it to the event handler if we do have a
+    // valid item index and haven't filled it yet (e.g. for LVN_ITEMCHANGED)
+    if ( event.m_itemIndex != -1 && !event.m_item.GetMask() )
+    {
+        wxListItem& item = event.m_item;
+
+        item.SetId(event.m_itemIndex);
+        item.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE | wxLIST_MASK_DATA);
+        GetItem(item);
+    }
+
     bool processed = HandleWindowEvent(event);
 
     // post processing
     bool processed = HandleWindowEvent(event);
 
     // post processing